Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Feature ➾ Allow docker images to be overwritten via environment variable (#1425) #1445

Merged
merged 15 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,8 @@ const exposeTask = (
cliConfig.command({
command: task.command,
aliases: task.aliases,
description: task.description,
hidden: task.hidden,
description: task.hidden ? null : task.description,
example: task.example,
builder: (cliConfig: CLIConfig) => {
if (task.options) {
Expand Down
62 changes: 31 additions & 31 deletions deno-lock.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/deno/ts-pattern.js": "139329135ba186e1f4d171fb5f8c4412f634b516cd86d9eebd144c818c8b4690",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/guards.d.ts": "23d3ac26c35d4ea250f4f6fa07b659bd29c927a9b2820538566b6cb4430b28c3",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/index.d.ts": "9be090eb63ebe134cd5016ce8619bec07146219443604c34232a548303f262d8",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/symbols.d.ts": "98319b603cf3f3a8b5b2c41de042cde79d84b690f26c0b4685e4e672df8ca404",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/BuildMany.d.ts": "3674e53f36e6e41ba02338325facde0d9a955de5d7fd688498f587782db88093",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/DeepExclude.d.ts": "5c60171c7dd994fe164c8bbf3fc8ea24c38e59b28d591f5aabeff38ec88c6412",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/DistributeUnions.d.ts": "ea6d9a52a1dcafa3e3b00638585ab474f1ee12742047df8650f2dafda2e7b23e",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/ExtractPreciseValue.d.ts": "9e1e400b20494dfc0b76dbb958fbeb4d1ab1d466ede399d68cf0f48f0fb8c739",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/FindSelected.d.ts": "566c9855f7664544a79da7c90fa5f7d9d56410984e7fed1692860df71c121ebb",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/InvertPattern.d.ts": "02923619121da147c587d07cf4fe44cff411ff30f1f73c73e75d7649ff680407",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/IsMatching.d.ts": "cec8189326776ce185aaec51fca5e7614febfd698371250fe5f05ce839ace71e",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/Match.d.ts": "63e07e40910e6e8d4c4f08027aca1e7397aa31673a9dbfed50c9442b0800995b",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/Pattern.d.ts": "f30e3728c2943012603e55ab32cf3553ecf62a4cb90702169bddd8028aee7a35",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/types/helpers.d.ts": "93e97f7a2715e8391e59ffd02e23773fdd9184c041719cb4e52821501b3995d0",
"https://cdn.esm.sh/v76/ts-pattern@3.3.5/lib/wildcards.d.ts": "c1bfcc56d4e49285e3254b407a36325dd2f099dba94fe7dee68d992d1fc35429",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/deno/ts-pattern.js": "8c2bb24215369ea60f00888d9bd6d31e2f5541e75b1ef9f423ab20a21e80d99b",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/guards.d.ts": "23d3ac26c35d4ea250f4f6fa07b659bd29c927a9b2820538566b6cb4430b28c3",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/index.d.ts": "9be090eb63ebe134cd5016ce8619bec07146219443604c34232a548303f262d8",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/symbols.d.ts": "98319b603cf3f3a8b5b2c41de042cde79d84b690f26c0b4685e4e672df8ca404",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/types/BuildMany.d.ts": "3674e53f36e6e41ba02338325facde0d9a955de5d7fd688498f587782db88093",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/types/DeepExclude.d.ts": "5c60171c7dd994fe164c8bbf3fc8ea24c38e59b28d591f5aabeff38ec88c6412",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/types/DistributeUnions.d.ts": "ea6d9a52a1dcafa3e3b00638585ab474f1ee12742047df8650f2dafda2e7b23e",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/types/ExtractPreciseValue.d.ts": "9e1e400b20494dfc0b76dbb958fbeb4d1ab1d466ede399d68cf0f48f0fb8c739",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/types/FindSelected.d.ts": "566c9855f7664544a79da7c90fa5f7d9d56410984e7fed1692860df71c121ebb",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/types/InvertPattern.d.ts": "02923619121da147c587d07cf4fe44cff411ff30f1f73c73e75d7649ff680407",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/types/IsMatching.d.ts": "cec8189326776ce185aaec51fca5e7614febfd698371250fe5f05ce839ace71e",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/types/Match.d.ts": "63e07e40910e6e8d4c4f08027aca1e7397aa31673a9dbfed50c9442b0800995b",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/types/Pattern.d.ts": "f30e3728c2943012603e55ab32cf3553ecf62a4cb90702169bddd8028aee7a35",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/types/helpers.d.ts": "93e97f7a2715e8391e59ffd02e23773fdd9184c041719cb4e52821501b3995d0",
"https://cdn.esm.sh/v74/ts-pattern@3.3.5/lib/wildcards.d.ts": "c1bfcc56d4e49285e3254b407a36325dd2f099dba94fe7dee68d992d1fc35429",
"https://cdn.jsdelivr.net/gh/fluture-js/Fluture@14.0.0/dist/module.js": "c11481f8a52a4ceabe6fb971abd0783b79ed7eb8a3eb2e2c4f3a3c8a1afa3303",
"https://cdn.jsdelivr.net/gh/fluture-js/Fluture@14.0.0/index.d.ts": "7f0d5888ab9f39515ee8f83df99377f63428ae65aa5e4daf3034035c773ea211",
"https://cdn.skypack.dev/-/batching-toposort@v1.2.0-dHlz5M75ZjMJ8fm1NtwH/dist=es2019,mode=imports/optimized/batching-toposort.js": "9508ff2861e25b728b4015df6a75aae993195da7279ec92a59294ba825751d6e",
Expand Down Expand Up @@ -48,28 +48,28 @@
"https://deno.land/std@0.120.0/path/posix.ts": "34349174b9cd121625a2810837a82dd8b986bbaaad5ade690d1de75bbb4555b2",
"https://deno.land/std@0.120.0/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c",
"https://deno.land/std@0.120.0/path/win32.ts": "11549e8c6df8307a8efcfa47ad7b2a75da743eac7d4c89c9723a944661c8bd2e",
"https://deno.land/std@0.123.0/_util/assert.ts": "2f868145a042a11d5ad0a3c748dcf580add8a0dbc0e876eaa0026303a5488f58",
"https://deno.land/std@0.123.0/_util/os.ts": "dfb186cc4e968c770ab6cc3288bd65f4871be03b93beecae57d657232ecffcac",
"https://deno.land/std@0.123.0/fmt/colors.ts": "8368ddf2d48dfe413ffd04cdbb7ae6a1009cf0dccc9c7ff1d76259d9c61a0621",
"https://deno.land/std@0.123.0/fmt/printf.ts": "419510e0a3f7c8d680fbf6472d5a11e372854f1c2b32fca5fdb513575c485068",
"https://deno.land/std@0.123.0/path/_constants.ts": "1247fee4a79b70c89f23499691ef169b41b6ccf01887a0abd131009c5581b853",
"https://deno.land/std@0.123.0/path/_interface.ts": "1fa73b02aaa24867e481a48492b44f2598cd9dfa513c7b34001437007d3642e4",
"https://deno.land/std@0.123.0/path/_util.ts": "2e06a3b9e79beaf62687196bd4b60a4c391d862cfa007a20fc3a39f778ba073b",
"https://deno.land/std@0.123.0/path/common.ts": "f41a38a0719a1e85aa11c6ba3bea5e37c15dd009d705bd8873f94c833568cbc4",
"https://deno.land/std@0.123.0/path/glob.ts": "7bf2349e818e332a830f3d8874c3f45dd7580b6c742ed50dbf6282d84ab18405",
"https://deno.land/std@0.123.0/path/mod.ts": "4465dc494f271b02569edbb4a18d727063b5dbd6ed84283ff906260970a15d12",
"https://deno.land/std@0.123.0/path/posix.ts": "34349174b9cd121625a2810837a82dd8b986bbaaad5ade690d1de75bbb4555b2",
"https://deno.land/std@0.123.0/path/separator.ts": "8fdcf289b1b76fd726a508f57d3370ca029ae6976fcde5044007f062e643ff1c",
"https://deno.land/std@0.123.0/path/win32.ts": "11549e8c6df8307a8efcfa47ad7b2a75da743eac7d4c89c9723a944661c8bd2e",
"https://deno.land/std@0.123.0/testing/_diff.ts": "e6a10d2aca8d6c27a9c5b8a2dbbf64353874730af539707b5b39d4128140642d",
"https://deno.land/std@0.123.0/testing/asserts.ts": "437505f8490a4d261836d822d3418bdd2b152007bdc9b01bdc339bf4b88983a2",
"https://deno.land/std@0.128.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74",
"https://deno.land/std@0.128.0/bytes/bytes_list.ts": "67eb118e0b7891d2f389dad4add35856f4ad5faab46318ff99653456c23b025d",
"https://deno.land/std@0.128.0/bytes/equals.ts": "fc16dff2090cced02497f16483de123dfa91e591029f985029193dfaa9d894c9",
"https://deno.land/std@0.128.0/bytes/mod.ts": "d3b455c0dbd4804644159d1e25946ade5ee385d2359894de49e2c6101b18b7a9",
"https://deno.land/std@0.128.0/io/buffer.ts": "bd0c4bf53db4b4be916ca5963e454bddfd3fcd45039041ea161dbf826817822b",
"https://deno.land/std@0.128.0/io/types.d.ts": "01f60ae7ec02675b5dbed150d258fc184a78dfe5c209ef53ba4422b46b58822c",
"https://deno.land/std@0.128.0/streams/conversion.ts": "712585bfa0172a97fb68dd46e784ae8ad59d11b88079d6a4ab098ff42e697d21",
"https://deno.land/std@0.133.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74",
"https://deno.land/std@0.133.0/_util/os.ts": "49b92edea1e82ba295ec946de8ffd956ed123e2948d9bd1d3e901b04e4307617",
"https://deno.land/std@0.133.0/fmt/colors.ts": "30455035d6d728394781c10755351742dd731e3db6771b1843f9b9e490104d37",
"https://deno.land/std@0.133.0/fmt/printf.ts": "e2c0f72146aed1efecf0c39ab928b26ae493a2278f670a871a0fbdcf36ff3379",
"https://deno.land/std@0.133.0/path/_constants.ts": "df1db3ffa6dd6d1252cc9617e5d72165cd2483df90e93833e13580687b6083c3",
"https://deno.land/std@0.133.0/path/_interface.ts": "ee3b431a336b80cf445441109d089b70d87d5e248f4f90ff906820889ecf8d09",
"https://deno.land/std@0.133.0/path/_util.ts": "c1e9686d0164e29f7d880b2158971d805b6e0efc3110d0b3e24e4b8af2190d2b",
"https://deno.land/std@0.133.0/path/common.ts": "bee563630abd2d97f99d83c96c2fa0cca7cee103e8cb4e7699ec4d5db7bd2633",
"https://deno.land/std@0.133.0/path/glob.ts": "cb5255638de1048973c3e69e420c77dc04f75755524cb3b2e160fe9277d939ee",
"https://deno.land/std@0.133.0/path/mod.ts": "4275129bb766f0e475ecc5246aa35689eeade419d72a48355203f31802640be7",
"https://deno.land/std@0.133.0/path/posix.ts": "663e4a6fe30a145f56aa41a22d95114c4c5582d8b57d2d7c9ed27ad2c47636bb",
"https://deno.land/std@0.133.0/path/separator.ts": "fe1816cb765a8068afb3e8f13ad272351c85cbc739af56dacfc7d93d710fe0f9",
"https://deno.land/std@0.133.0/path/win32.ts": "e7bdf63e8d9982b4d8a01ef5689425c93310ece950e517476e22af10f41a136e",
"https://deno.land/std@0.133.0/testing/_diff.ts": "9d849cd6877694152e01775b2d93f9d6b7aef7e24bfe3bfafc4d7a1ac8e9f392",
"https://deno.land/std@0.133.0/testing/asserts.ts": "b0ef969032882b1f7eb1c7571e313214baa1485f7b61cf35807b2434e254365c",
"https://deno.land/std@0.85.0/async/deferred.ts": "f89ed49ba5e1dd0227c6bd5b23f017be46c3f92e4f0338dda08ff5aa54b9f6c9",
"https://deno.land/std@0.85.0/async/delay.ts": "9de1d8d07d1927767ab7f82434b883f3d8294fb19cad819691a2ad81a728cf3d",
"https://deno.land/std@0.85.0/async/mod.ts": "253b41c658d768613eacfb11caa0a9ca7148442f932018a45576f7f27554c853",
Expand Down Expand Up @@ -546,6 +546,6 @@
"https://deno.land/x/zod@v3.14.4/index.ts": "035a7422d9f2be54daa0fe464254b69225b443000673e4794095d672471e8792",
"https://deno.land/x/zod@v3.14.4/mod.ts": "64e55237cb4410e17d968cd08975566059f27638ebb0b86048031b987ba251c4",
"https://deno.land/x/zod@v3.14.4/types.ts": "7829a9fe28910b928e13de4b1b7ae72798ab09934daf69f3ef9d7ce52d0d5663",
"https://esm.sh/ts-pattern@3.3.5": "13920cf5529bab1debc7df1be8bc57d914bf2d80cd81c452df8045af0da67f2d",
"https://esm.sh/ts-pattern@3.3.5": "68b836c71a4de8d4b55fd8469d517ab80bb4cc7969a8db6ad25f9fe5b15815bf",
"https://raw.githubusercontent.com/mweichert/clipboard/master/mod.ts": "6368780ee65d9f034a23b7d525229947e02f141a16f1678f2b25735f391a2c6e"
}
46 changes: 30 additions & 16 deletions taqueria-plugin-archetype/compile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { execCmd, getContracts, sendAsyncErr, sendErr, sendJsonRes } from '@taqueria/node-sdk';
import {
execCmd,
getContracts,
getDockerImage,
sendAsyncErr,
sendAsyncRes,
sendErr,
sendJsonRes,
} from '@taqueria/node-sdk';
import { RequestArgs, TaqError } from '@taqueria/node-sdk/types';
import { basename, extname, join } from 'path';
import { match } from 'ts-pattern';

interface Opts extends RequestArgs.t {
const DOCKER_IMAGE = getDockerImage('completium/archetype:1.2.12', 'TAQ_ARCHETYPE_IMAGE');

interface Opts extends RequestArgs.ProxyRequestArgs {
sourceFile?: string;
}

Expand All @@ -23,7 +34,7 @@ const getCompileCommand = (opts: Opts) =>
const { projectDir } = opts;
const inputFile = getInputFilename(opts)(sourceFile);
const baseCommand =
`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -u $(id -u):$(id -g) -w /project completium/archetype:1.2.12 ${inputFile}`;
`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -u $(id -u):$(id -g) -w /project ${DOCKER_IMAGE} ${inputFile}`;
const outFile = `-o ${getContractArtifactFilename(opts)(sourceFile)}`;
const cmd = `${baseCommand} ${outFile}`;
return cmd;
Expand Down Expand Up @@ -59,19 +70,22 @@ const compileAll = (opts: Opts): Promise<{ contract: string; artifact: string }[
)
.then(promises => Promise.all(promises));

const compile = <T>(parsedArgs: Opts) => {
const p = parsedArgs.sourceFile
? compileContract(parsedArgs)(parsedArgs.sourceFile)
.then(result => [result])
: compileAll(parsedArgs)
.then(results => {
if (results.length === 0) sendErr('No contracts found to compile.');
return results;
});
const compile = <T>(parsedArgs: Opts) =>
match(parsedArgs)
.when(opts => opts.task === 'get-image', () => sendAsyncRes(DOCKER_IMAGE))
.otherwise(() => {
const p = parsedArgs.sourceFile
? compileContract(parsedArgs)(parsedArgs.sourceFile)
.then(result => [result])
: compileAll(parsedArgs)
.then(results => {
if (results.length === 0) sendErr('No contracts found to compile.');
return results;
});

return p
.then(sendJsonRes)
.catch(err => sendAsyncErr(err, false));
};
return p
.then(sendJsonRes)
.catch(err => sendAsyncErr(err, false));
});

export default compile;
7 changes: 7 additions & 0 deletions taqueria-plugin-archetype/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ Plugin.create(i18n => ({
handler: 'proxy',
encoding: 'json',
}),
Task.create({
task: 'get-image',
command: 'get-image',
description: 'Gets the name of the image to be used',
handler: 'proxy',
hidden: true,
}),
],
templates: [
Template.create({
Expand Down
3 changes: 2 additions & 1 deletion taqueria-plugin-archetype/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"homepage": "https://github.com/ecadlabs/taqueria#readme",
"dependencies": {
"@taqueria/node-sdk": "^0.22.2",
"fast-glob": "^3.2.11"
"fast-glob": "^3.2.11",
"ts-pattern": "^4.0.5"
},
"devDependencies": {
"parcel": "2.6.1",
Expand Down
5 changes: 3 additions & 2 deletions taqueria-plugin-flextesa/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
execCmd,
getArch,
getDockerImage,
readJsonFile,
sendAsyncErr,
sendAsyncRes,
Expand Down Expand Up @@ -30,7 +31,7 @@ export interface Opts extends RequestArgs.ProxyRequestArgs {
sandboxName?: string;
}

const getDockerImage = (opts: Opts) => `ghcr.io/ecadlabs/taqueria-flextesa:${opts.setVersion}-${opts.setBuild}`;
const getDefaultDockerImage = (opts: Opts) => `ghcr.io/ecadlabs/taqueria-flextesa:${opts.setVersion}-${opts.setBuild}`;

export const getUniqueSandboxName = async (sandboxName: string, projectDir: string) => {
const hash = await stringToSHA256(projectDir);
Expand Down Expand Up @@ -91,7 +92,7 @@ const getStartCommand = async (sandboxName: string, sandbox: SandboxConfig.t, op

const containerName = await getContainerName(sandboxName, opts);
const arch = await getArch();
const image = getDockerImage(opts);
const image = getDockerImage(getDefaultDockerImage(opts), 'TAQ_FLEXTESA_IMAGE');
const projectDir = process.env.PROJECT_DIR ?? opts.config.projectDir;

return `docker run --network sandbox_${sandboxName}_net --name ${containerName} --rm --detach --platform ${arch} ${ports} -v ${projectDir}:/project -w /app ${image} node index.js --sandbox ${sandboxName}`;
Expand Down
3 changes: 2 additions & 1 deletion taqueria-plugin-ligo/common.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getDockerImage } from '@taqueria/node-sdk';
import { RequestArgs } from '@taqueria/node-sdk/types';
import { join } from 'path';

Expand All @@ -18,7 +19,7 @@ export type IntersectionOpts = LigoOpts & CompileOpts & TestOpts;
type UnionOpts = LigoOpts | CompileOpts | TestOpts;

// Points to the latest stable version. Needs to update this as part of our release process
export const LIGO_DOCKER_IMAGE = 'ligolang/ligo:0.51.0';
export const LIGO_DOCKER_IMAGE = getDockerImage('ligolang/ligo:0.51.0', 'TAQ_LIGO_IMAGE');
mweichert marked this conversation as resolved.
Show resolved Hide resolved

export const getInputFilename = (parsedArgs: UnionOpts, sourceFile: string): string =>
join(parsedArgs.config.contractsDir, sourceFile);
3 changes: 2 additions & 1 deletion taqueria-plugin-ligo/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ const compileContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow
})
.catch(err => {
sendErr(`\n=== For ${sourceFile} ===`);
sendErr(err.message.replace(/Command failed.+?\n/, ''));
sendErr(err.toString());
mweichert marked this conversation as resolved.
Show resolved Hide resolved
if (err.message) sendErr(err.message.replace(/Command failed.+?\n/, ''));
return {
contract: sourceFile,
artifact: COMPILE_ERR_MSG,
Expand Down
7 changes: 7 additions & 0 deletions taqueria-plugin-ligo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ Plugin.create(i18n => ({
handler: 'proxy',
encoding: 'json',
}),
Task.create({
task: 'get-image',
command: 'get-image',
description: 'Gets the name of the image to be used',
handler: 'proxy',
hidden: true,
}),
],
templates: [
Template.create({
Expand Down
6 changes: 4 additions & 2 deletions taqueria-plugin-ligo/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sendAsyncErr } from '@taqueria/node-sdk';
import { IntersectionOpts as Opts } from './common';
import { sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
import { IntersectionOpts as Opts, LIGO_DOCKER_IMAGE } from './common';
import compile from './compile';
import ligo from './ligo';
import test from './test';
Expand All @@ -12,6 +12,8 @@ const main = (parsedArgs: Opts): Promise<void> => {
return compile(parsedArgs);
case 'test':
return test(parsedArgs);
case 'get-image':
return sendAsyncRes(LIGO_DOCKER_IMAGE);
default:
return sendAsyncErr(`${parsedArgs.task} is not an understood task by the LIGO plugin`);
}
Expand Down
6 changes: 3 additions & 3 deletions taqueria-plugin-tezos-client/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CmdArgEnv, getArch, getFlextesaImage, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';
import { ClientOpts as Opts } from './common';
import { CmdArgEnv, getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';
import { ClientOpts as Opts, DOCKER_IMAGE } from './common';

const getArbitraryClientCmd = async (
parsedArgs: Opts,
Expand All @@ -8,7 +8,7 @@ const getArbitraryClientCmd = async (
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
if (!projectDir) throw `No project directory provided`;
const arch = await getArch();
const flextesaImage = await getFlextesaImage(arch);
const flextesaImage = DOCKER_IMAGE;
const binary = 'docker';
const baseArgs = [
'run',
Expand Down
11 changes: 7 additions & 4 deletions taqueria-plugin-tezos-client/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { getArch, getFlextesaImage } from '@taqueria/node-sdk';
import { getArchSync, getDockerImage } from '@taqueria/node-sdk';
import { RequestArgs } from '@taqueria/node-sdk/types';
import { join } from 'path';

export const getFlextesaImage = (arch: 'linux/arm64/v8' | 'linux/amd64'): string =>
arch === 'linux/arm64/v8' ? 'oxheadalpha/flextesa:rc-20220915-arm64' : 'oxheadalpha/flextesa:20220715';

export const DOCKER_IMAGE = getDockerImage(getFlextesaImage(getArchSync()), 'TAQ_TEZOS_CLIENT_IMAGE');
export interface ClientOpts extends RequestArgs.ProxyRequestArgs {
command: string;
}
Expand Down Expand Up @@ -34,9 +38,8 @@ export const getInputFilename = (opts: UnionOpts, sourceFile: string) =>
export const getCheckFileExistenceCommand = async (parsedArgs: UnionOpts, sourceFile: string): Promise<string> => {
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
if (!projectDir) throw `No project directory provided`;
const arch = await getArch();
const flextesaImage = await getFlextesaImage(arch);
const baseCmd = `docker run --rm -v \"${projectDir}\":/project -w /project --platform ${arch} ${flextesaImage} ls`;
const arch = getArchSync();
const baseCmd = `docker run --rm -v \"${projectDir}\":/project -w /project --platform ${arch} ${DOCKER_IMAGE} ls`;
const inputFile = getInputFilename(parsedArgs, sourceFile);
const cmd = `${baseCmd} ${inputFile}`;
return cmd;
Expand Down
7 changes: 7 additions & 0 deletions taqueria-plugin-tezos-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ Plugin.create(i18n => ({
],
encoding: 'json',
}),
Task.create({
task: 'get-image',
command: 'get-image',
description: 'Gets the name of the image to be used',
handler: 'proxy',
hidden: true,
}),
],
proxy: main,
}), process.argv);
6 changes: 4 additions & 2 deletions taqueria-plugin-tezos-client/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { sendAsyncErr } from '@taqueria/node-sdk';
import { sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
import client from './client';
import { IntersectionOpts as Opts } from './common';
import { DOCKER_IMAGE, IntersectionOpts as Opts } from './common';
import simulate from './simulate';
import typecheck from './typecheck';

Expand All @@ -12,6 +12,8 @@ const main = (parsedArgs: Opts): Promise<void> => {
return typecheck(parsedArgs);
case 'simulate':
return simulate(parsedArgs);
case 'get-image':
return sendAsyncRes(DOCKER_IMAGE);
default:
return sendAsyncErr(`${parsedArgs.task} is not an understood task by the Tezos-client plugin`);
}
Expand Down
Loading