@taqueria/plugin-smartpy-legacy 0.56.15 → 0.57.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -14
- package/index.js.map +1 -1
- package/index.mjs +7 -14
- package/index.mjs.map +1 -1
- package/package.json +77 -77
package/index.js
CHANGED
|
@@ -80,8 +80,7 @@ var getCompilationTargetsDirname = (parsedArgs, sourceFile) => (0, import_path.j
|
|
|
80
80
|
var installSmartPyCliIfNotExist = (projectDir) => (0, import_promises.access)(getSmartPyCli()).catch(() => {
|
|
81
81
|
(0, import_node_sdk.sendWarn)("SmartPy CLI not found. Installing it now...");
|
|
82
82
|
return (0, import_node_sdk.execCmd)(getSmartPyInstallerCmd(projectDir)).then(({ stderr }) => {
|
|
83
|
-
if (stderr.length > 0)
|
|
84
|
-
(0, import_node_sdk.sendWarn)(stderr);
|
|
83
|
+
if (stderr.length > 0) (0, import_node_sdk.sendWarn)(stderr);
|
|
85
84
|
});
|
|
86
85
|
});
|
|
87
86
|
var emitExternalError = (err, sourceFile) => {
|
|
@@ -117,8 +116,7 @@ var getCompilationTargetNames = (parsedArgs, sourceFile) => (0, import_promises2
|
|
|
117
116
|
exprCompTargetNames: data.match(/(?<=add_expression_compilation_target\s*\(\s*['"])[^'"]+(?=['"])/g) ?? []
|
|
118
117
|
}));
|
|
119
118
|
var copyArtifactsForFirstCompTarget = async (parsedArgs, sourceFile, compTargetNames) => {
|
|
120
|
-
if (compTargetNames.length === 0)
|
|
121
|
-
return [];
|
|
119
|
+
if (compTargetNames.length === 0) return [];
|
|
122
120
|
const firstCompTargetName = compTargetNames.slice(0, 1)[0];
|
|
123
121
|
const dstContractPath = getOutputContractFilename(parsedArgs, sourceFile);
|
|
124
122
|
await (0, import_promises2.copyFile)(
|
|
@@ -141,8 +139,7 @@ var copyArtifactsForFirstCompTarget = async (parsedArgs, sourceFile, compTargetN
|
|
|
141
139
|
return [dstContractPath, dstDefaultStoragePath];
|
|
142
140
|
};
|
|
143
141
|
var copyArtifactsForRestCompTargets = async (parsedArgs, sourceFile, compTargetNames) => {
|
|
144
|
-
if (compTargetNames.length === 0)
|
|
145
|
-
return [];
|
|
142
|
+
if (compTargetNames.length === 0) return [];
|
|
146
143
|
const restCompTargetNames = compTargetNames.slice(1, compTargetNames.length);
|
|
147
144
|
const dstStoragePaths = await Promise.all(restCompTargetNames.map(async (compTargetName) => {
|
|
148
145
|
const dstStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, compTargetName, false);
|
|
@@ -159,8 +156,7 @@ var copyArtifactsForRestCompTargets = async (parsedArgs, sourceFile, compTargetN
|
|
|
159
156
|
return dstStoragePaths;
|
|
160
157
|
};
|
|
161
158
|
var copyArtifactsForExprCompTargets = async (parsedArgs, sourceFile, exprCompTargetNames) => {
|
|
162
|
-
if (exprCompTargetNames.length === 0)
|
|
163
|
-
return [];
|
|
159
|
+
if (exprCompTargetNames.length === 0) return [];
|
|
164
160
|
const dstExprPaths = await Promise.all(exprCompTargetNames.map(async (compTargetName) => {
|
|
165
161
|
const dstExprPath = getOutputExprFilename(parsedArgs, sourceFile, compTargetName);
|
|
166
162
|
await (0, import_promises2.copyFile)(
|
|
@@ -176,8 +172,7 @@ var copyArtifactsForExprCompTargets = async (parsedArgs, sourceFile, exprCompTar
|
|
|
176
172
|
return dstExprPaths;
|
|
177
173
|
};
|
|
178
174
|
var copyRelevantArtifactsForCompTargets = (parsedArgs, sourceFile) => async ({ compTargetNames, exprCompTargetNames }) => {
|
|
179
|
-
if (compTargetNames.length === 0 && exprCompTargetNames.length === 0)
|
|
180
|
-
return "No compilation targets defined";
|
|
175
|
+
if (compTargetNames.length === 0 && exprCompTargetNames.length === 0) return "No compilation targets defined";
|
|
181
176
|
const dstContractAndDefaultStoragePaths = await copyArtifactsForFirstCompTarget(
|
|
182
177
|
parsedArgs,
|
|
183
178
|
sourceFile,
|
|
@@ -201,8 +196,7 @@ var getCompileContractCmd = (parsedArgs, sourceFile) => {
|
|
|
201
196
|
return `${getSmartPyCli()} compile ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;
|
|
202
197
|
};
|
|
203
198
|
var compileContract = (parsedArgs, sourceFile) => (0, import_node_sdk2.getArch)().then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir)).then(() => getCompileContractCmd(parsedArgs, sourceFile)).then(import_node_sdk2.execCmd).then(({ stderr }) => {
|
|
204
|
-
if (stderr.length > 0)
|
|
205
|
-
(0, import_node_sdk2.sendWarn)(stderr);
|
|
199
|
+
if (stderr.length > 0) (0, import_node_sdk2.sendWarn)(stderr);
|
|
206
200
|
}).then(() => getCompilationTargetNames(parsedArgs, sourceFile)).then(copyRelevantArtifactsForCompTargets(parsedArgs, sourceFile)).then((relevantArtifacts) => ({
|
|
207
201
|
contract: sourceFile,
|
|
208
202
|
artifact: relevantArtifacts
|
|
@@ -245,8 +239,7 @@ var getTestContractCmd = (parsedArgs, sourceFile) => {
|
|
|
245
239
|
return `${getSmartPyCli()} test ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;
|
|
246
240
|
};
|
|
247
241
|
var testContract = (parsedArgs, sourceFile) => (0, import_node_sdk4.getArch)().then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir)).then(() => getTestContractCmd(parsedArgs, sourceFile)).then(import_node_sdk4.execCmd).then(({ stdout, stderr }) => {
|
|
248
|
-
if (stderr.length > 0)
|
|
249
|
-
(0, import_node_sdk4.sendWarn)(stderr);
|
|
242
|
+
if (stderr.length > 0) (0, import_node_sdk4.sendWarn)(stderr);
|
|
250
243
|
const result = "\u{1F389} All tests passed \u{1F389}";
|
|
251
244
|
return {
|
|
252
245
|
contract: sourceFile,
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts","main.ts","compile.ts","common.ts","compileAll.ts","test.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport main from './main';\n\nPlugin.create(i18n => ({\n\talias: 'smartpy',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'compile',\n\t\t\tcommand: 'compile <sourceFile>',\n\t\t\taliases: ['c', 'compile-smartpy'],\n\t\t\tdescription:\n\t\t\t\t'Compile a smart contract written in a SmartPy syntax to Michelson code, along with its associated storage values, per compilation targets, and some expressions per expression compilation targets',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'json',\n\t\t\t\t\tboolean: true,\n\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'compile-all',\n\t\t\tcommand: 'compile-all',\n\t\t\tdescription:\n\t\t\t\t'Compile all SmartPy smart contracts with at least one SmartPy compilation target to Michelson code, along with their associated storage values, per compilation targets, and some expressions per expression compilation targets',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'json',\n\t\t\t\t\tboolean: true,\n\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test <sourceFile>',\n\t\t\tdescription: 'Test a smart contract written in SmartPy',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';\nimport { IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport compileAll from './compileAll';\nimport test from './test';\n\nconst main = (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst unsafeArgs = parsedArgs as Opts;\n\tswitch (unsafeArgs.task) {\n\t\tcase 'compile':\n\t\t\treturn compile(unsafeArgs);\n\t\tcase 'compile-all':\n\t\t\treturn compileAll(unsafeArgs);\n\t\tcase 'test':\n\t\t\treturn test(unsafeArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeArgs.task} is not an understood task by the SmartPy plugin`);\n\t}\n};\n\nexport default main;\n","import { execCmd, getArch, getArtifactsDir, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { copyFile, readFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport {\n\taddPyExtensionIfMissing,\n\tCompileOpts as Opts,\n\temitExternalError,\n\tgetCompilationTargetsDirname,\n\tgetInputFilename,\n\tgetSmartPyCli,\n\tinstallSmartPyCliIfNotExist,\n} from './common';\n\nexport type TableRow = { contract: string; artifact: string };\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isOutputFormatJSON = (parsedArgs: Opts): boolean => parsedArgs.json;\n\nconst getOutputContractFilename = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), `${outputFile}${ext}`);\n};\n\nconst getOutputStorageFilename = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompilationTargetName: string,\n\tisDefaultStorage: boolean,\n): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst storageName = isDefaultStorage\n\t\t? `${outputFile}.default_storage${ext}`\n\t\t: `${outputFile}.storage.${compilationTargetName}${ext}`;\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), storageName);\n};\n\nconst getOutputExprFilename = (parsedArgs: Opts, sourceFile: string, compilationTargetName: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst exprName = `${outputFile}.expression.${compilationTargetName}${ext}`;\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), exprName);\n};\n\nconst getCompilationTargetNames = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n): Promise<{ compTargetNames: string[]; exprCompTargetNames: string[] }> =>\n\treadFile(getInputFilename(parsedArgs, sourceFile), 'utf8')\n\t\t.then(data => ({\n\t\t\tcompTargetNames: data.match(/(?<=add_compilation_target\\s*\\(\\s*['\"])[^'\"]+(?=['\"])/g) ?? [],\n\t\t\texprCompTargetNames: data.match(/(?<=add_expression_compilation_target\\s*\\(\\s*['\"])[^'\"]+(?=['\"])/g) ?? [],\n\t\t}));\n\nconst copyArtifactsForFirstCompTarget = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompTargetNames: string[],\n): Promise<string[]> => {\n\tif (compTargetNames.length === 0) return [];\n\tconst firstCompTargetName = compTargetNames.slice(0, 1)[0];\n\n\tconst dstContractPath = getOutputContractFilename(parsedArgs, sourceFile);\n\tawait copyFile(\n\t\tjoin(\n\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\tfirstCompTargetName,\n\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_contract.json' : 'step_000_cont_0_contract.tz',\n\t\t),\n\t\tdstContractPath,\n\t);\n\n\tconst dstDefaultStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, firstCompTargetName, true);\n\tawait copyFile(\n\t\tjoin(\n\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\tfirstCompTargetName,\n\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_storage.json' : 'step_000_cont_0_storage.tz',\n\t\t),\n\t\tdstDefaultStoragePath,\n\t);\n\n\treturn [dstContractPath, dstDefaultStoragePath];\n};\n\nconst copyArtifactsForRestCompTargets = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompTargetNames: string[],\n): Promise<string[]> => {\n\tif (compTargetNames.length === 0) return [];\n\tconst restCompTargetNames = compTargetNames.slice(1, compTargetNames.length);\n\n\tconst dstStoragePaths = await Promise.all(restCompTargetNames.map(async compTargetName => {\n\t\tconst dstStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, compTargetName, false);\n\t\tawait copyFile(\n\t\t\tjoin(\n\t\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\t\tcompTargetName,\n\t\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_storage.json' : 'step_000_cont_0_storage.tz',\n\t\t\t),\n\t\t\tdstStoragePath,\n\t\t);\n\t\treturn dstStoragePath;\n\t}));\n\n\treturn dstStoragePaths;\n};\n\nconst copyArtifactsForExprCompTargets = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\texprCompTargetNames: string[],\n): Promise<string[]> => {\n\tif (exprCompTargetNames.length === 0) return [];\n\n\tconst dstExprPaths = await Promise.all(exprCompTargetNames.map(async compTargetName => {\n\t\tconst dstExprPath = getOutputExprFilename(parsedArgs, sourceFile, compTargetName);\n\t\tawait copyFile(\n\t\t\tjoin(\n\t\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\t\tcompTargetName,\n\t\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_expression.json' : 'step_000_expression.tz',\n\t\t\t),\n\t\t\tdstExprPath,\n\t\t);\n\t\treturn dstExprPath;\n\t}));\n\n\treturn dstExprPaths;\n};\n\nconst copyRelevantArtifactsForCompTargets = (parsedArgs: Opts, sourceFile: string) =>\nasync (\n\t{ compTargetNames, exprCompTargetNames }: { compTargetNames: string[]; exprCompTargetNames: string[] },\n): Promise<string> => {\n\tif (compTargetNames.length === 0 && exprCompTargetNames.length === 0) return 'No compilation targets defined';\n\n\tconst dstContractAndDefaultStoragePaths = await copyArtifactsForFirstCompTarget(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\tcompTargetNames,\n\t);\n\n\tconst dstStoragePaths = await copyArtifactsForRestCompTargets(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\tcompTargetNames,\n\t);\n\n\tconst dstExpressionPaths = await copyArtifactsForExprCompTargets(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\texprCompTargetNames,\n\t);\n\n\treturn dstContractAndDefaultStoragePaths.concat(dstStoragePaths).concat(dstExpressionPaths).join('\\n');\n};\n\nconst getCompileContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);\n\tconst booleanFlags = ' --html --purge ';\n\treturn `${getSmartPyCli()} compile ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;\n};\n\nexport const compileContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir))\n\t\t.then(() => getCompileContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t})\n\t\t.then(() => getCompilationTargetNames(parsedArgs, sourceFile))\n\t\t.then(copyRelevantArtifactsForCompTargets(parsedArgs, sourceFile))\n\t\t.then(relevantArtifacts => ({\n\t\t\tcontract: sourceFile,\n\t\t\tartifact: relevantArtifacts,\n\t\t}))\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t});\n\nconst compile = (parsedArgs: Opts): Promise<void> =>\n\tcompileContract(parsedArgs, addPyExtensionIfMissing(parsedArgs.sourceFile))\n\t\t.then(result => [result])\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendAsyncErr(err, false));\n\nexport default compile;\n","import { execCmd, getArtifactsDir, getContractsDir, sendErr, sendWarn } from '@taqueria/node-sdk';\nimport { ProxyTaskArgs } from '@taqueria/node-sdk/types';\nimport { access, copyFile, readdir, stat } from 'fs/promises';\nimport { join } from 'path';\n\nexport interface CompileOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n\tjson: boolean;\n}\n\nexport interface CompileAllOpts extends ProxyTaskArgs.t {\n\tjson: boolean;\n}\n\nexport interface TestOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n}\n\nexport type IntersectionOpts = CompileOpts & CompileAllOpts & TestOpts;\n\ntype UnionOpts = CompileOpts | CompileAllOpts | TestOpts;\n\n// Should point to the latest stable version, so it needs to be updated as part of our release process.\nconst SMARTPY_DEFAULT_VERSION = 'v0.16.0';\n\nconst SMARTPY_VERSION_ENV_VAR = 'TAQ_SMARTPY_VERSION';\n\nconst SMARTPY_ARTIFACTS_DIR = '.smartpy';\n\nconst smartpyVersionToInstallerMap: { [k: string]: string } = {\n\t'v0.16.0': 'https://smartpy.io/releases/20221215-8f134ebb649f5a7b37c44fca8f336f970f523565/cli/install.sh',\n};\n\nconst getSmartpyVersion = (): string => {\n\tconst userDefinedSmartpyVersion = process.env[SMARTPY_VERSION_ENV_VAR];\n\tif (userDefinedSmartpyVersion) {\n\t\tif (/v0\\.1[4-6]\\./.test(userDefinedSmartpyVersion)) {\n\t\t\treturn userDefinedSmartpyVersion;\n\t\t} else {\n\t\t\tsendWarn(\n\t\t\t\t`Version ${userDefinedSmartpyVersion} is not supported by Taqueria yet. The supported versions are [${\n\t\t\t\t\tObject.keys(smartpyVersionToInstallerMap)\n\t\t\t\t}]. Will default to ${SMARTPY_DEFAULT_VERSION}`,\n\t\t\t);\n\t\t\treturn SMARTPY_DEFAULT_VERSION;\n\t\t}\n\t} else {\n\t\treturn SMARTPY_DEFAULT_VERSION;\n\t}\n};\n\nconst getPathToSmartPyCliDir = (): string => `${process.env.HOME}/smartpy-cli-${getSmartpyVersion()}`;\n\nexport const getSmartPyCli = (): string => `${getPathToSmartPyCliDir()}/SmartPy.sh`;\n\nconst getSmartPyInstallerCmd = (projectDir: string): string => {\n\tconst trimmedProjectdir = projectDir.replace(/\\/$/, '');\n\tconst installer = join(__dirname, 'install.sh');\n\tconst install = `bash ${installer} --yes --prefix ${getPathToSmartPyCliDir()} --project ${trimmedProjectdir};`;\n\treturn install;\n};\n\nexport const addPyExtensionIfMissing = (sourceFile: string): string =>\n\t/\\.py$/.test(sourceFile) ? sourceFile : `${sourceFile}.py`;\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.py$/);\n\treturn matchResult ? matchResult[0] : '';\n};\n\nconst removeExt = (path: string): string => {\n\tconst extRegex = new RegExp(extractExt(path));\n\treturn path.replace(extRegex, '');\n};\n\nexport const getInputFilename = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, getContractsDir(parsedArgs), sourceFile);\n\nexport const getCompilationTargetsDirname = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), SMARTPY_ARTIFACTS_DIR, removeExt(sourceFile));\n\nexport const installSmartPyCliIfNotExist = (projectDir: string) =>\n\taccess(getSmartPyCli())\n\t\t.catch(() => {\n\t\t\tsendWarn('SmartPy CLI not found. Installing it now...');\n\t\t\treturn execCmd(getSmartPyInstallerCmd(projectDir))\n\t\t\t\t.then(({ stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\t});\n\t\t});\n\nexport const emitExternalError = (err: unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== Error messages for ${sourceFile} ===`);\n\terr instanceof Error ? sendErr(err.message.replace(/Command failed.+?\\n/, '')) : sendErr(err as any);\n\tsendErr(`\\n===`);\n};\n","import { getContractsDir, sendAsyncErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { CompileAllOpts as Opts, CompileOpts, getInputFilename } from './common';\nimport { compileContract, TableRow } from './compile';\n\nconst contractHasCompTarget = (parsedArgs: Opts, contactFilename: string): Promise<boolean> =>\n\treadFile(getInputFilename(parsedArgs, contactFilename), 'utf8')\n\t\t.then(data => /add_(expression_)?compilation_target\\s*\\(\\s*['\"][^'\"]+['\"]/.test(data));\n\nconst compileAll = async (parsedArgs: Opts): Promise<void> => {\n\tlet p: Promise<TableRow>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.py'],\n\t\t{ cwd: join(parsedArgs.config.projectDir, getContractsDir(parsedArgs)), absolute: false },\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (await contractHasCompTarget(parsedArgs, filename)) {\n\t\t\tp.push(compileContract(parsedArgs as CompileOpts, filename));\n\t\t}\n\t}\n\n\treturn Promise.all(p).then(sendJsonRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default compileAll;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport {\n\taddPyExtensionIfMissing,\n\temitExternalError,\n\tgetCompilationTargetsDirname,\n\tgetInputFilename,\n\tgetSmartPyCli,\n\tinstallSmartPyCliIfNotExist,\n\tTestOpts as Opts,\n} from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);\n\tconst booleanFlags = ' --html --purge ';\n\treturn `${getSmartPyCli()} test ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;\n};\n\nconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir))\n\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stdout, stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t};\n\t\t})\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t};\n\t\t});\n\nconst test = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = addPyExtensionIfMissing(parsedArgs.sourceFile);\n\treturn testContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>\n\t\tsendAsyncErr(err, false)\n\t);\n};\n\nexport default test;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,mBAAqC;;;ACArC,IAAAC,mBAA0C;;;ACA1C,IAAAC,mBAAuF;AACvF,IAAAC,mBAAmC;AACnC,IAAAC,eAAwC;;;ACFxC,sBAA6E;AAE7E,sBAAgD;AAChD,kBAAqB;AAoBrB,IAAM,0BAA0B;AAEhC,IAAM,0BAA0B;AAEhC,IAAM,wBAAwB;AAE9B,IAAM,+BAAwD;AAAA,EAC7D,WAAW;AACZ;AAEA,IAAM,oBAAoB,MAAc;AACvC,QAAM,4BAA4B,QAAQ,IAAI,uBAAuB;AACrE,MAAI,2BAA2B;AAC9B,QAAI,eAAe,KAAK,yBAAyB,GAAG;AACnD,aAAO;AAAA,IACR,OAAO;AACN;AAAA,QACC,WAAW,yBAAyB,kEACnC,OAAO,KAAK,4BAA4B,CACzC,sBAAsB,uBAAuB;AAAA,MAC9C;AACA,aAAO;AAAA,IACR;AAAA,EACD,OAAO;AACN,WAAO;AAAA,EACR;AACD;AAEA,IAAM,yBAAyB,MAAc,GAAG,QAAQ,IAAI,IAAI,gBAAgB,kBAAkB,CAAC;AAE5F,IAAM,gBAAgB,MAAc,GAAG,uBAAuB,CAAC;AAEtE,IAAM,yBAAyB,CAAC,eAA+B;AAC9D,QAAM,oBAAoB,WAAW,QAAQ,OAAO,EAAE;AACtD,QAAM,gBAAY,kBAAK,WAAW,YAAY;AAC9C,QAAM,UAAU,QAAQ,SAAS,mB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,UACT,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["import_node_sdk","import_node_sdk","import_node_sdk","import_promises","import_path","import_node_sdk","import_promises","import_path","glob","import_node_sdk"]}
|
|
1
|
+
{"version":3,"sources":["index.ts","main.ts","compile.ts","common.ts","compileAll.ts","test.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport main from './main';\n\nPlugin.create(i18n => ({\n\talias: 'smartpy',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'compile',\n\t\t\tcommand: 'compile <sourceFile>',\n\t\t\taliases: ['c', 'compile-smartpy'],\n\t\t\tdescription:\n\t\t\t\t'Compile a smart contract written in a SmartPy syntax to Michelson code, along with its associated storage values, per compilation targets, and some expressions per expression compilation targets',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'json',\n\t\t\t\t\tboolean: true,\n\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'compile-all',\n\t\t\tcommand: 'compile-all',\n\t\t\tdescription:\n\t\t\t\t'Compile all SmartPy smart contracts with at least one SmartPy compilation target to Michelson code, along with their associated storage values, per compilation targets, and some expressions per expression compilation targets',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'json',\n\t\t\t\t\tboolean: true,\n\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test <sourceFile>',\n\t\t\tdescription: 'Test a smart contract written in SmartPy',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';\nimport { IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport compileAll from './compileAll';\nimport test from './test';\n\nconst main = (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst unsafeArgs = parsedArgs as Opts;\n\tswitch (unsafeArgs.task) {\n\t\tcase 'compile':\n\t\t\treturn compile(unsafeArgs);\n\t\tcase 'compile-all':\n\t\t\treturn compileAll(unsafeArgs);\n\t\tcase 'test':\n\t\t\treturn test(unsafeArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeArgs.task} is not an understood task by the SmartPy plugin`);\n\t}\n};\n\nexport default main;\n","import { execCmd, getArch, getArtifactsDir, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { copyFile, readFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport {\n\taddPyExtensionIfMissing,\n\tCompileOpts as Opts,\n\temitExternalError,\n\tgetCompilationTargetsDirname,\n\tgetInputFilename,\n\tgetSmartPyCli,\n\tinstallSmartPyCliIfNotExist,\n} from './common';\n\nexport type TableRow = { contract: string; artifact: string };\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isOutputFormatJSON = (parsedArgs: Opts): boolean => parsedArgs.json;\n\nconst getOutputContractFilename = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), `${outputFile}${ext}`);\n};\n\nconst getOutputStorageFilename = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompilationTargetName: string,\n\tisDefaultStorage: boolean,\n): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst storageName = isDefaultStorage\n\t\t? `${outputFile}.default_storage${ext}`\n\t\t: `${outputFile}.storage.${compilationTargetName}${ext}`;\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), storageName);\n};\n\nconst getOutputExprFilename = (parsedArgs: Opts, sourceFile: string, compilationTargetName: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst exprName = `${outputFile}.expression.${compilationTargetName}${ext}`;\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), exprName);\n};\n\nconst getCompilationTargetNames = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n): Promise<{ compTargetNames: string[]; exprCompTargetNames: string[] }> =>\n\treadFile(getInputFilename(parsedArgs, sourceFile), 'utf8')\n\t\t.then(data => ({\n\t\t\tcompTargetNames: data.match(/(?<=add_compilation_target\\s*\\(\\s*['\"])[^'\"]+(?=['\"])/g) ?? [],\n\t\t\texprCompTargetNames: data.match(/(?<=add_expression_compilation_target\\s*\\(\\s*['\"])[^'\"]+(?=['\"])/g) ?? [],\n\t\t}));\n\nconst copyArtifactsForFirstCompTarget = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompTargetNames: string[],\n): Promise<string[]> => {\n\tif (compTargetNames.length === 0) return [];\n\tconst firstCompTargetName = compTargetNames.slice(0, 1)[0];\n\n\tconst dstContractPath = getOutputContractFilename(parsedArgs, sourceFile);\n\tawait copyFile(\n\t\tjoin(\n\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\tfirstCompTargetName,\n\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_contract.json' : 'step_000_cont_0_contract.tz',\n\t\t),\n\t\tdstContractPath,\n\t);\n\n\tconst dstDefaultStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, firstCompTargetName, true);\n\tawait copyFile(\n\t\tjoin(\n\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\tfirstCompTargetName,\n\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_storage.json' : 'step_000_cont_0_storage.tz',\n\t\t),\n\t\tdstDefaultStoragePath,\n\t);\n\n\treturn [dstContractPath, dstDefaultStoragePath];\n};\n\nconst copyArtifactsForRestCompTargets = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompTargetNames: string[],\n): Promise<string[]> => {\n\tif (compTargetNames.length === 0) return [];\n\tconst restCompTargetNames = compTargetNames.slice(1, compTargetNames.length);\n\n\tconst dstStoragePaths = await Promise.all(restCompTargetNames.map(async compTargetName => {\n\t\tconst dstStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, compTargetName, false);\n\t\tawait copyFile(\n\t\t\tjoin(\n\t\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\t\tcompTargetName,\n\t\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_storage.json' : 'step_000_cont_0_storage.tz',\n\t\t\t),\n\t\t\tdstStoragePath,\n\t\t);\n\t\treturn dstStoragePath;\n\t}));\n\n\treturn dstStoragePaths;\n};\n\nconst copyArtifactsForExprCompTargets = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\texprCompTargetNames: string[],\n): Promise<string[]> => {\n\tif (exprCompTargetNames.length === 0) return [];\n\n\tconst dstExprPaths = await Promise.all(exprCompTargetNames.map(async compTargetName => {\n\t\tconst dstExprPath = getOutputExprFilename(parsedArgs, sourceFile, compTargetName);\n\t\tawait copyFile(\n\t\t\tjoin(\n\t\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\t\tcompTargetName,\n\t\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_expression.json' : 'step_000_expression.tz',\n\t\t\t),\n\t\t\tdstExprPath,\n\t\t);\n\t\treturn dstExprPath;\n\t}));\n\n\treturn dstExprPaths;\n};\n\nconst copyRelevantArtifactsForCompTargets = (parsedArgs: Opts, sourceFile: string) =>\nasync (\n\t{ compTargetNames, exprCompTargetNames }: { compTargetNames: string[]; exprCompTargetNames: string[] },\n): Promise<string> => {\n\tif (compTargetNames.length === 0 && exprCompTargetNames.length === 0) return 'No compilation targets defined';\n\n\tconst dstContractAndDefaultStoragePaths = await copyArtifactsForFirstCompTarget(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\tcompTargetNames,\n\t);\n\n\tconst dstStoragePaths = await copyArtifactsForRestCompTargets(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\tcompTargetNames,\n\t);\n\n\tconst dstExpressionPaths = await copyArtifactsForExprCompTargets(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\texprCompTargetNames,\n\t);\n\n\treturn dstContractAndDefaultStoragePaths.concat(dstStoragePaths).concat(dstExpressionPaths).join('\\n');\n};\n\nconst getCompileContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);\n\tconst booleanFlags = ' --html --purge ';\n\treturn `${getSmartPyCli()} compile ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;\n};\n\nexport const compileContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir))\n\t\t.then(() => getCompileContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t})\n\t\t.then(() => getCompilationTargetNames(parsedArgs, sourceFile))\n\t\t.then(copyRelevantArtifactsForCompTargets(parsedArgs, sourceFile))\n\t\t.then(relevantArtifacts => ({\n\t\t\tcontract: sourceFile,\n\t\t\tartifact: relevantArtifacts,\n\t\t}))\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t});\n\nconst compile = (parsedArgs: Opts): Promise<void> =>\n\tcompileContract(parsedArgs, addPyExtensionIfMissing(parsedArgs.sourceFile))\n\t\t.then(result => [result])\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendAsyncErr(err, false));\n\nexport default compile;\n","import { execCmd, getArtifactsDir, getContractsDir, sendErr, sendWarn } from '@taqueria/node-sdk';\nimport { ProxyTaskArgs } from '@taqueria/node-sdk/types';\nimport { access, copyFile, readdir, stat } from 'fs/promises';\nimport { join } from 'path';\n\nexport interface CompileOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n\tjson: boolean;\n}\n\nexport interface CompileAllOpts extends ProxyTaskArgs.t {\n\tjson: boolean;\n}\n\nexport interface TestOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n}\n\nexport type IntersectionOpts = CompileOpts & CompileAllOpts & TestOpts;\n\ntype UnionOpts = CompileOpts | CompileAllOpts | TestOpts;\n\n// Should point to the latest stable version, so it needs to be updated as part of our release process.\nconst SMARTPY_DEFAULT_VERSION = 'v0.16.0';\n\nconst SMARTPY_VERSION_ENV_VAR = 'TAQ_SMARTPY_VERSION';\n\nconst SMARTPY_ARTIFACTS_DIR = '.smartpy';\n\nconst smartpyVersionToInstallerMap: { [k: string]: string } = {\n\t'v0.16.0': 'https://smartpy.io/releases/20221215-8f134ebb649f5a7b37c44fca8f336f970f523565/cli/install.sh',\n};\n\nconst getSmartpyVersion = (): string => {\n\tconst userDefinedSmartpyVersion = process.env[SMARTPY_VERSION_ENV_VAR];\n\tif (userDefinedSmartpyVersion) {\n\t\tif (/v0\\.1[4-6]\\./.test(userDefinedSmartpyVersion)) {\n\t\t\treturn userDefinedSmartpyVersion;\n\t\t} else {\n\t\t\tsendWarn(\n\t\t\t\t`Version ${userDefinedSmartpyVersion} is not supported by Taqueria yet. The supported versions are [${\n\t\t\t\t\tObject.keys(smartpyVersionToInstallerMap)\n\t\t\t\t}]. Will default to ${SMARTPY_DEFAULT_VERSION}`,\n\t\t\t);\n\t\t\treturn SMARTPY_DEFAULT_VERSION;\n\t\t}\n\t} else {\n\t\treturn SMARTPY_DEFAULT_VERSION;\n\t}\n};\n\nconst getPathToSmartPyCliDir = (): string => `${process.env.HOME}/smartpy-cli-${getSmartpyVersion()}`;\n\nexport const getSmartPyCli = (): string => `${getPathToSmartPyCliDir()}/SmartPy.sh`;\n\nconst getSmartPyInstallerCmd = (projectDir: string): string => {\n\tconst trimmedProjectdir = projectDir.replace(/\\/$/, '');\n\tconst installer = join(__dirname, 'install.sh');\n\tconst install = `bash ${installer} --yes --prefix ${getPathToSmartPyCliDir()} --project ${trimmedProjectdir};`;\n\treturn install;\n};\n\nexport const addPyExtensionIfMissing = (sourceFile: string): string =>\n\t/\\.py$/.test(sourceFile) ? sourceFile : `${sourceFile}.py`;\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.py$/);\n\treturn matchResult ? matchResult[0] : '';\n};\n\nconst removeExt = (path: string): string => {\n\tconst extRegex = new RegExp(extractExt(path));\n\treturn path.replace(extRegex, '');\n};\n\nexport const getInputFilename = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, getContractsDir(parsedArgs), sourceFile);\n\nexport const getCompilationTargetsDirname = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), SMARTPY_ARTIFACTS_DIR, removeExt(sourceFile));\n\nexport const installSmartPyCliIfNotExist = (projectDir: string) =>\n\taccess(getSmartPyCli())\n\t\t.catch(() => {\n\t\t\tsendWarn('SmartPy CLI not found. Installing it now...');\n\t\t\treturn execCmd(getSmartPyInstallerCmd(projectDir))\n\t\t\t\t.then(({ stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\t});\n\t\t});\n\nexport const emitExternalError = (err: unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== Error messages for ${sourceFile} ===`);\n\terr instanceof Error ? sendErr(err.message.replace(/Command failed.+?\\n/, '')) : sendErr(err as any);\n\tsendErr(`\\n===`);\n};\n","import { getContractsDir, sendAsyncErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { CompileAllOpts as Opts, CompileOpts, getInputFilename } from './common';\nimport { compileContract, TableRow } from './compile';\n\nconst contractHasCompTarget = (parsedArgs: Opts, contactFilename: string): Promise<boolean> =>\n\treadFile(getInputFilename(parsedArgs, contactFilename), 'utf8')\n\t\t.then(data => /add_(expression_)?compilation_target\\s*\\(\\s*['\"][^'\"]+['\"]/.test(data));\n\nconst compileAll = async (parsedArgs: Opts): Promise<void> => {\n\tlet p: Promise<TableRow>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.py'],\n\t\t{ cwd: join(parsedArgs.config.projectDir, getContractsDir(parsedArgs)), absolute: false },\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (await contractHasCompTarget(parsedArgs, filename)) {\n\t\t\tp.push(compileContract(parsedArgs as CompileOpts, filename));\n\t\t}\n\t}\n\n\treturn Promise.all(p).then(sendJsonRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default compileAll;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport {\n\taddPyExtensionIfMissing,\n\temitExternalError,\n\tgetCompilationTargetsDirname,\n\tgetInputFilename,\n\tgetSmartPyCli,\n\tinstallSmartPyCliIfNotExist,\n\tTestOpts as Opts,\n} from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);\n\tconst booleanFlags = ' --html --purge ';\n\treturn `${getSmartPyCli()} test ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;\n};\n\nconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir))\n\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stdout, stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t};\n\t\t})\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t};\n\t\t});\n\nconst test = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = addPyExtensionIfMissing(parsedArgs.sourceFile);\n\treturn testContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>\n\t\tsendAsyncErr(err, false)\n\t);\n};\n\nexport default test;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,mBAAqC;;;ACArC,IAAAC,mBAA0C;;;ACA1C,IAAAC,mBAAuF;AACvF,IAAAC,mBAAmC;AACnC,IAAAC,eAAwC;;;ACFxC,sBAA6E;AAE7E,sBAAgD;AAChD,kBAAqB;AAoBrB,IAAM,0BAA0B;AAEhC,IAAM,0BAA0B;AAEhC,IAAM,wBAAwB;AAE9B,IAAM,+BAAwD;AAAA,EAC7D,WAAW;AACZ;AAEA,IAAM,oBAAoB,MAAc;AACvC,QAAM,4BAA4B,QAAQ,IAAI,uBAAuB;AACrE,MAAI,2BAA2B;AAC9B,QAAI,eAAe,KAAK,yBAAyB,GAAG;AACnD,aAAO;AAAA,IACR,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AAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,KAAK,iBAAiB;AAAA,MAChC,aACC;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,MACV,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACC;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,MACV,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,IACD,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["import_node_sdk","import_node_sdk","import_node_sdk","import_promises","import_path","import_node_sdk","import_promises","import_path","glob","import_node_sdk"]}
|
package/index.mjs
CHANGED
|
@@ -56,8 +56,7 @@ var getCompilationTargetsDirname = (parsedArgs, sourceFile) => join(parsedArgs.c
|
|
|
56
56
|
var installSmartPyCliIfNotExist = (projectDir) => access(getSmartPyCli()).catch(() => {
|
|
57
57
|
sendWarn("SmartPy CLI not found. Installing it now...");
|
|
58
58
|
return execCmd(getSmartPyInstallerCmd(projectDir)).then(({ stderr }) => {
|
|
59
|
-
if (stderr.length > 0)
|
|
60
|
-
sendWarn(stderr);
|
|
59
|
+
if (stderr.length > 0) sendWarn(stderr);
|
|
61
60
|
});
|
|
62
61
|
});
|
|
63
62
|
var emitExternalError = (err, sourceFile) => {
|
|
@@ -93,8 +92,7 @@ var getCompilationTargetNames = (parsedArgs, sourceFile) => readFile(getInputFil
|
|
|
93
92
|
exprCompTargetNames: data.match(/(?<=add_expression_compilation_target\s*\(\s*['"])[^'"]+(?=['"])/g) ?? []
|
|
94
93
|
}));
|
|
95
94
|
var copyArtifactsForFirstCompTarget = async (parsedArgs, sourceFile, compTargetNames) => {
|
|
96
|
-
if (compTargetNames.length === 0)
|
|
97
|
-
return [];
|
|
95
|
+
if (compTargetNames.length === 0) return [];
|
|
98
96
|
const firstCompTargetName = compTargetNames.slice(0, 1)[0];
|
|
99
97
|
const dstContractPath = getOutputContractFilename(parsedArgs, sourceFile);
|
|
100
98
|
await copyFile2(
|
|
@@ -117,8 +115,7 @@ var copyArtifactsForFirstCompTarget = async (parsedArgs, sourceFile, compTargetN
|
|
|
117
115
|
return [dstContractPath, dstDefaultStoragePath];
|
|
118
116
|
};
|
|
119
117
|
var copyArtifactsForRestCompTargets = async (parsedArgs, sourceFile, compTargetNames) => {
|
|
120
|
-
if (compTargetNames.length === 0)
|
|
121
|
-
return [];
|
|
118
|
+
if (compTargetNames.length === 0) return [];
|
|
122
119
|
const restCompTargetNames = compTargetNames.slice(1, compTargetNames.length);
|
|
123
120
|
const dstStoragePaths = await Promise.all(restCompTargetNames.map(async (compTargetName) => {
|
|
124
121
|
const dstStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, compTargetName, false);
|
|
@@ -135,8 +132,7 @@ var copyArtifactsForRestCompTargets = async (parsedArgs, sourceFile, compTargetN
|
|
|
135
132
|
return dstStoragePaths;
|
|
136
133
|
};
|
|
137
134
|
var copyArtifactsForExprCompTargets = async (parsedArgs, sourceFile, exprCompTargetNames) => {
|
|
138
|
-
if (exprCompTargetNames.length === 0)
|
|
139
|
-
return [];
|
|
135
|
+
if (exprCompTargetNames.length === 0) return [];
|
|
140
136
|
const dstExprPaths = await Promise.all(exprCompTargetNames.map(async (compTargetName) => {
|
|
141
137
|
const dstExprPath = getOutputExprFilename(parsedArgs, sourceFile, compTargetName);
|
|
142
138
|
await copyFile2(
|
|
@@ -152,8 +148,7 @@ var copyArtifactsForExprCompTargets = async (parsedArgs, sourceFile, exprCompTar
|
|
|
152
148
|
return dstExprPaths;
|
|
153
149
|
};
|
|
154
150
|
var copyRelevantArtifactsForCompTargets = (parsedArgs, sourceFile) => async ({ compTargetNames, exprCompTargetNames }) => {
|
|
155
|
-
if (compTargetNames.length === 0 && exprCompTargetNames.length === 0)
|
|
156
|
-
return "No compilation targets defined";
|
|
151
|
+
if (compTargetNames.length === 0 && exprCompTargetNames.length === 0) return "No compilation targets defined";
|
|
157
152
|
const dstContractAndDefaultStoragePaths = await copyArtifactsForFirstCompTarget(
|
|
158
153
|
parsedArgs,
|
|
159
154
|
sourceFile,
|
|
@@ -177,8 +172,7 @@ var getCompileContractCmd = (parsedArgs, sourceFile) => {
|
|
|
177
172
|
return `${getSmartPyCli()} compile ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;
|
|
178
173
|
};
|
|
179
174
|
var compileContract = (parsedArgs, sourceFile) => getArch().then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir)).then(() => getCompileContractCmd(parsedArgs, sourceFile)).then(execCmd2).then(({ stderr }) => {
|
|
180
|
-
if (stderr.length > 0)
|
|
181
|
-
sendWarn2(stderr);
|
|
175
|
+
if (stderr.length > 0) sendWarn2(stderr);
|
|
182
176
|
}).then(() => getCompilationTargetNames(parsedArgs, sourceFile)).then(copyRelevantArtifactsForCompTargets(parsedArgs, sourceFile)).then((relevantArtifacts) => ({
|
|
183
177
|
contract: sourceFile,
|
|
184
178
|
artifact: relevantArtifacts
|
|
@@ -221,8 +215,7 @@ var getTestContractCmd = (parsedArgs, sourceFile) => {
|
|
|
221
215
|
return `${getSmartPyCli()} test ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;
|
|
222
216
|
};
|
|
223
217
|
var testContract = (parsedArgs, sourceFile) => getArch2().then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir)).then(() => getTestContractCmd(parsedArgs, sourceFile)).then(execCmd3).then(({ stdout, stderr }) => {
|
|
224
|
-
if (stderr.length > 0)
|
|
225
|
-
sendWarn3(stderr);
|
|
218
|
+
if (stderr.length > 0) sendWarn3(stderr);
|
|
226
219
|
const result = "\u{1F389} All tests passed \u{1F389}";
|
|
227
220
|
return {
|
|
228
221
|
contract: sourceFile,
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts","main.ts","compile.ts","common.ts","compileAll.ts","test.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport main from './main';\n\nPlugin.create(i18n => ({\n\talias: 'smartpy',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'compile',\n\t\t\tcommand: 'compile <sourceFile>',\n\t\t\taliases: ['c', 'compile-smartpy'],\n\t\t\tdescription:\n\t\t\t\t'Compile a smart contract written in a SmartPy syntax to Michelson code, along with its associated storage values, per compilation targets, and some expressions per expression compilation targets',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'json',\n\t\t\t\t\tboolean: true,\n\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'compile-all',\n\t\t\tcommand: 'compile-all',\n\t\t\tdescription:\n\t\t\t\t'Compile all SmartPy smart contracts with at least one SmartPy compilation target to Michelson code, along with their associated storage values, per compilation targets, and some expressions per expression compilation targets',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'json',\n\t\t\t\t\tboolean: true,\n\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test <sourceFile>',\n\t\t\tdescription: 'Test a smart contract written in SmartPy',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';\nimport { IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport compileAll from './compileAll';\nimport test from './test';\n\nconst main = (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst unsafeArgs = parsedArgs as Opts;\n\tswitch (unsafeArgs.task) {\n\t\tcase 'compile':\n\t\t\treturn compile(unsafeArgs);\n\t\tcase 'compile-all':\n\t\t\treturn compileAll(unsafeArgs);\n\t\tcase 'test':\n\t\t\treturn test(unsafeArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeArgs.task} is not an understood task by the SmartPy plugin`);\n\t}\n};\n\nexport default main;\n","import { execCmd, getArch, getArtifactsDir, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { copyFile, readFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport {\n\taddPyExtensionIfMissing,\n\tCompileOpts as Opts,\n\temitExternalError,\n\tgetCompilationTargetsDirname,\n\tgetInputFilename,\n\tgetSmartPyCli,\n\tinstallSmartPyCliIfNotExist,\n} from './common';\n\nexport type TableRow = { contract: string; artifact: string };\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isOutputFormatJSON = (parsedArgs: Opts): boolean => parsedArgs.json;\n\nconst getOutputContractFilename = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), `${outputFile}${ext}`);\n};\n\nconst getOutputStorageFilename = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompilationTargetName: string,\n\tisDefaultStorage: boolean,\n): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst storageName = isDefaultStorage\n\t\t? `${outputFile}.default_storage${ext}`\n\t\t: `${outputFile}.storage.${compilationTargetName}${ext}`;\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), storageName);\n};\n\nconst getOutputExprFilename = (parsedArgs: Opts, sourceFile: string, compilationTargetName: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst exprName = `${outputFile}.expression.${compilationTargetName}${ext}`;\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), exprName);\n};\n\nconst getCompilationTargetNames = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n): Promise<{ compTargetNames: string[]; exprCompTargetNames: string[] }> =>\n\treadFile(getInputFilename(parsedArgs, sourceFile), 'utf8')\n\t\t.then(data => ({\n\t\t\tcompTargetNames: data.match(/(?<=add_compilation_target\\s*\\(\\s*['\"])[^'\"]+(?=['\"])/g) ?? [],\n\t\t\texprCompTargetNames: data.match(/(?<=add_expression_compilation_target\\s*\\(\\s*['\"])[^'\"]+(?=['\"])/g) ?? [],\n\t\t}));\n\nconst copyArtifactsForFirstCompTarget = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompTargetNames: string[],\n): Promise<string[]> => {\n\tif (compTargetNames.length === 0) return [];\n\tconst firstCompTargetName = compTargetNames.slice(0, 1)[0];\n\n\tconst dstContractPath = getOutputContractFilename(parsedArgs, sourceFile);\n\tawait copyFile(\n\t\tjoin(\n\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\tfirstCompTargetName,\n\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_contract.json' : 'step_000_cont_0_contract.tz',\n\t\t),\n\t\tdstContractPath,\n\t);\n\n\tconst dstDefaultStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, firstCompTargetName, true);\n\tawait copyFile(\n\t\tjoin(\n\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\tfirstCompTargetName,\n\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_storage.json' : 'step_000_cont_0_storage.tz',\n\t\t),\n\t\tdstDefaultStoragePath,\n\t);\n\n\treturn [dstContractPath, dstDefaultStoragePath];\n};\n\nconst copyArtifactsForRestCompTargets = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompTargetNames: string[],\n): Promise<string[]> => {\n\tif (compTargetNames.length === 0) return [];\n\tconst restCompTargetNames = compTargetNames.slice(1, compTargetNames.length);\n\n\tconst dstStoragePaths = await Promise.all(restCompTargetNames.map(async compTargetName => {\n\t\tconst dstStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, compTargetName, false);\n\t\tawait copyFile(\n\t\t\tjoin(\n\t\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\t\tcompTargetName,\n\t\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_storage.json' : 'step_000_cont_0_storage.tz',\n\t\t\t),\n\t\t\tdstStoragePath,\n\t\t);\n\t\treturn dstStoragePath;\n\t}));\n\n\treturn dstStoragePaths;\n};\n\nconst copyArtifactsForExprCompTargets = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\texprCompTargetNames: string[],\n): Promise<string[]> => {\n\tif (exprCompTargetNames.length === 0) return [];\n\n\tconst dstExprPaths = await Promise.all(exprCompTargetNames.map(async compTargetName => {\n\t\tconst dstExprPath = getOutputExprFilename(parsedArgs, sourceFile, compTargetName);\n\t\tawait copyFile(\n\t\t\tjoin(\n\t\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\t\tcompTargetName,\n\t\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_expression.json' : 'step_000_expression.tz',\n\t\t\t),\n\t\t\tdstExprPath,\n\t\t);\n\t\treturn dstExprPath;\n\t}));\n\n\treturn dstExprPaths;\n};\n\nconst copyRelevantArtifactsForCompTargets = (parsedArgs: Opts, sourceFile: string) =>\nasync (\n\t{ compTargetNames, exprCompTargetNames }: { compTargetNames: string[]; exprCompTargetNames: string[] },\n): Promise<string> => {\n\tif (compTargetNames.length === 0 && exprCompTargetNames.length === 0) return 'No compilation targets defined';\n\n\tconst dstContractAndDefaultStoragePaths = await copyArtifactsForFirstCompTarget(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\tcompTargetNames,\n\t);\n\n\tconst dstStoragePaths = await copyArtifactsForRestCompTargets(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\tcompTargetNames,\n\t);\n\n\tconst dstExpressionPaths = await copyArtifactsForExprCompTargets(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\texprCompTargetNames,\n\t);\n\n\treturn dstContractAndDefaultStoragePaths.concat(dstStoragePaths).concat(dstExpressionPaths).join('\\n');\n};\n\nconst getCompileContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);\n\tconst booleanFlags = ' --html --purge ';\n\treturn `${getSmartPyCli()} compile ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;\n};\n\nexport const compileContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir))\n\t\t.then(() => getCompileContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t})\n\t\t.then(() => getCompilationTargetNames(parsedArgs, sourceFile))\n\t\t.then(copyRelevantArtifactsForCompTargets(parsedArgs, sourceFile))\n\t\t.then(relevantArtifacts => ({\n\t\t\tcontract: sourceFile,\n\t\t\tartifact: relevantArtifacts,\n\t\t}))\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t});\n\nconst compile = (parsedArgs: Opts): Promise<void> =>\n\tcompileContract(parsedArgs, addPyExtensionIfMissing(parsedArgs.sourceFile))\n\t\t.then(result => [result])\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendAsyncErr(err, false));\n\nexport default compile;\n","import { execCmd, getArtifactsDir, getContractsDir, sendErr, sendWarn } from '@taqueria/node-sdk';\nimport { ProxyTaskArgs } from '@taqueria/node-sdk/types';\nimport { access, copyFile, readdir, stat } from 'fs/promises';\nimport { join } from 'path';\n\nexport interface CompileOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n\tjson: boolean;\n}\n\nexport interface CompileAllOpts extends ProxyTaskArgs.t {\n\tjson: boolean;\n}\n\nexport interface TestOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n}\n\nexport type IntersectionOpts = CompileOpts & CompileAllOpts & TestOpts;\n\ntype UnionOpts = CompileOpts | CompileAllOpts | TestOpts;\n\n// Should point to the latest stable version, so it needs to be updated as part of our release process.\nconst SMARTPY_DEFAULT_VERSION = 'v0.16.0';\n\nconst SMARTPY_VERSION_ENV_VAR = 'TAQ_SMARTPY_VERSION';\n\nconst SMARTPY_ARTIFACTS_DIR = '.smartpy';\n\nconst smartpyVersionToInstallerMap: { [k: string]: string } = {\n\t'v0.16.0': 'https://smartpy.io/releases/20221215-8f134ebb649f5a7b37c44fca8f336f970f523565/cli/install.sh',\n};\n\nconst getSmartpyVersion = (): string => {\n\tconst userDefinedSmartpyVersion = process.env[SMARTPY_VERSION_ENV_VAR];\n\tif (userDefinedSmartpyVersion) {\n\t\tif (/v0\\.1[4-6]\\./.test(userDefinedSmartpyVersion)) {\n\t\t\treturn userDefinedSmartpyVersion;\n\t\t} else {\n\t\t\tsendWarn(\n\t\t\t\t`Version ${userDefinedSmartpyVersion} is not supported by Taqueria yet. The supported versions are [${\n\t\t\t\t\tObject.keys(smartpyVersionToInstallerMap)\n\t\t\t\t}]. Will default to ${SMARTPY_DEFAULT_VERSION}`,\n\t\t\t);\n\t\t\treturn SMARTPY_DEFAULT_VERSION;\n\t\t}\n\t} else {\n\t\treturn SMARTPY_DEFAULT_VERSION;\n\t}\n};\n\nconst getPathToSmartPyCliDir = (): string => `${process.env.HOME}/smartpy-cli-${getSmartpyVersion()}`;\n\nexport const getSmartPyCli = (): string => `${getPathToSmartPyCliDir()}/SmartPy.sh`;\n\nconst getSmartPyInstallerCmd = (projectDir: string): string => {\n\tconst trimmedProjectdir = projectDir.replace(/\\/$/, '');\n\tconst installer = join(__dirname, 'install.sh');\n\tconst install = `bash ${installer} --yes --prefix ${getPathToSmartPyCliDir()} --project ${trimmedProjectdir};`;\n\treturn install;\n};\n\nexport const addPyExtensionIfMissing = (sourceFile: string): string =>\n\t/\\.py$/.test(sourceFile) ? sourceFile : `${sourceFile}.py`;\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.py$/);\n\treturn matchResult ? matchResult[0] : '';\n};\n\nconst removeExt = (path: string): string => {\n\tconst extRegex = new RegExp(extractExt(path));\n\treturn path.replace(extRegex, '');\n};\n\nexport const getInputFilename = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, getContractsDir(parsedArgs), sourceFile);\n\nexport const getCompilationTargetsDirname = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), SMARTPY_ARTIFACTS_DIR, removeExt(sourceFile));\n\nexport const installSmartPyCliIfNotExist = (projectDir: string) =>\n\taccess(getSmartPyCli())\n\t\t.catch(() => {\n\t\t\tsendWarn('SmartPy CLI not found. Installing it now...');\n\t\t\treturn execCmd(getSmartPyInstallerCmd(projectDir))\n\t\t\t\t.then(({ stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\t});\n\t\t});\n\nexport const emitExternalError = (err: unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== Error messages for ${sourceFile} ===`);\n\terr instanceof Error ? sendErr(err.message.replace(/Command failed.+?\\n/, '')) : sendErr(err as any);\n\tsendErr(`\\n===`);\n};\n","import { getContractsDir, sendAsyncErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { CompileAllOpts as Opts, CompileOpts, getInputFilename } from './common';\nimport { compileContract, TableRow } from './compile';\n\nconst contractHasCompTarget = (parsedArgs: Opts, contactFilename: string): Promise<boolean> =>\n\treadFile(getInputFilename(parsedArgs, contactFilename), 'utf8')\n\t\t.then(data => /add_(expression_)?compilation_target\\s*\\(\\s*['\"][^'\"]+['\"]/.test(data));\n\nconst compileAll = async (parsedArgs: Opts): Promise<void> => {\n\tlet p: Promise<TableRow>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.py'],\n\t\t{ cwd: join(parsedArgs.config.projectDir, getContractsDir(parsedArgs)), absolute: false },\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (await contractHasCompTarget(parsedArgs, filename)) {\n\t\t\tp.push(compileContract(parsedArgs as CompileOpts, filename));\n\t\t}\n\t}\n\n\treturn Promise.all(p).then(sendJsonRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default compileAll;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport {\n\taddPyExtensionIfMissing,\n\temitExternalError,\n\tgetCompilationTargetsDirname,\n\tgetInputFilename,\n\tgetSmartPyCli,\n\tinstallSmartPyCliIfNotExist,\n\tTestOpts as Opts,\n} from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);\n\tconst booleanFlags = ' --html --purge ';\n\treturn `${getSmartPyCli()} test ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;\n};\n\nconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir))\n\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stdout, stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t};\n\t\t})\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t};\n\t\t});\n\nconst test = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = addPyExtensionIfMissing(parsedArgs.sourceFile);\n\treturn testContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>\n\t\tsendAsyncErr(err, false)\n\t);\n};\n\nexport default test;\n"],"mappings":";AAAA,SAAS,QAAQ,QAAQ,YAAY;;;ACArC,SAAsB,gBAAAA,qBAAoB;;;ACA1C,SAAS,WAAAC,UAAS,SAAS,mBAAAC,kBAAiB,cAAc,aAAa,YAAAC,iBAAgB;AACvF,SAAS,YAAAC,WAAU,gBAAgB;AACnC,SAAS,UAAU,SAAS,QAAAC,aAAY;;;ACFxC,SAAS,SAAS,iBAAiB,iBAAiB,SAAS,gBAAgB;AAE7E,SAAS,cAAuC;AAChD,SAAS,YAAY;AAoBrB,IAAM,0BAA0B;AAEhC,IAAM,0BAA0B;AAEhC,IAAM,wBAAwB;AAE9B,IAAM,+BAAwD;AAAA,EAC7D,WAAW;AACZ;AAEA,IAAM,oBAAoB,MAAc;AACvC,QAAM,4BAA4B,QAAQ,IAAI,uBAAuB;AACrE,MAAI,2BAA2B;AAC9B,QAAI,eAAe,KA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Bf,OAAO,OAAO,WAAS;AAAA,EACtB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,IACN,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,SAAS,CAAC,KAAK,iBAAiB;AAAA,MAChC,aACC;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,MACV,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aACC;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,MACV,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["sendAsyncErr","execCmd","getArtifactsDir","sendWarn","copyFile","join","join","getArtifactsDir","copyFile","execCmd","sendWarn","getContractsDir","sendAsyncErr","sendJsonRes","readFile","join","readFile","join","getContractsDir","sendJsonRes","sendAsyncErr","execCmd","getArch","sendAsyncErr","sendJsonRes","sendWarn","getArch","execCmd","sendWarn","sendJsonRes","sendAsyncErr","sendAsyncErr"]}
|
|
1
|
+
{"version":3,"sources":["index.ts","main.ts","compile.ts","common.ts","compileAll.ts","test.ts"],"sourcesContent":["import { Option, Plugin, Task } from '@taqueria/node-sdk';\nimport main from './main';\n\nPlugin.create(i18n => ({\n\talias: 'smartpy',\n\tschema: '1.0',\n\tversion: '0.1',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'compile',\n\t\t\tcommand: 'compile <sourceFile>',\n\t\t\taliases: ['c', 'compile-smartpy'],\n\t\t\tdescription:\n\t\t\t\t'Compile a smart contract written in a SmartPy syntax to Michelson code, along with its associated storage values, per compilation targets, and some expressions per expression compilation targets',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'json',\n\t\t\t\t\tboolean: true,\n\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'compile-all',\n\t\t\tcommand: 'compile-all',\n\t\t\tdescription:\n\t\t\t\t'Compile all SmartPy smart contracts with at least one SmartPy compilation target to Michelson code, along with their associated storage values, per compilation targets, and some expressions per expression compilation targets',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'json',\n\t\t\t\t\tboolean: true,\n\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test <sourceFile>',\n\t\t\tdescription: 'Test a smart contract written in SmartPy',\n\t\t\thandler: 'proxy',\n\t\t\tencoding: 'json',\n\t\t}),\n\t],\n\tproxy: main,\n}), process.argv);\n","import { RequestArgs, sendAsyncErr } from '@taqueria/node-sdk';\nimport { IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport compileAll from './compileAll';\nimport test from './test';\n\nconst main = (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst unsafeArgs = parsedArgs as Opts;\n\tswitch (unsafeArgs.task) {\n\t\tcase 'compile':\n\t\t\treturn compile(unsafeArgs);\n\t\tcase 'compile-all':\n\t\t\treturn compileAll(unsafeArgs);\n\t\tcase 'test':\n\t\t\treturn test(unsafeArgs);\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeArgs.task} is not an understood task by the SmartPy plugin`);\n\t}\n};\n\nexport default main;\n","import { execCmd, getArch, getArtifactsDir, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { copyFile, readFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport {\n\taddPyExtensionIfMissing,\n\tCompileOpts as Opts,\n\temitExternalError,\n\tgetCompilationTargetsDirname,\n\tgetInputFilename,\n\tgetSmartPyCli,\n\tinstallSmartPyCliIfNotExist,\n} from './common';\n\nexport type TableRow = { contract: string; artifact: string };\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isOutputFormatJSON = (parsedArgs: Opts): boolean => parsedArgs.json;\n\nconst getOutputContractFilename = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), `${outputFile}${ext}`);\n};\n\nconst getOutputStorageFilename = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompilationTargetName: string,\n\tisDefaultStorage: boolean,\n): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst storageName = isDefaultStorage\n\t\t? `${outputFile}.default_storage${ext}`\n\t\t: `${outputFile}.storage.${compilationTargetName}${ext}`;\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), storageName);\n};\n\nconst getOutputExprFilename = (parsedArgs: Opts, sourceFile: string, compilationTargetName: string): string => {\n\tconst outputFile = basename(sourceFile, extname(sourceFile));\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst exprName = `${outputFile}.expression.${compilationTargetName}${ext}`;\n\treturn join(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), exprName);\n};\n\nconst getCompilationTargetNames = (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n): Promise<{ compTargetNames: string[]; exprCompTargetNames: string[] }> =>\n\treadFile(getInputFilename(parsedArgs, sourceFile), 'utf8')\n\t\t.then(data => ({\n\t\t\tcompTargetNames: data.match(/(?<=add_compilation_target\\s*\\(\\s*['\"])[^'\"]+(?=['\"])/g) ?? [],\n\t\t\texprCompTargetNames: data.match(/(?<=add_expression_compilation_target\\s*\\(\\s*['\"])[^'\"]+(?=['\"])/g) ?? [],\n\t\t}));\n\nconst copyArtifactsForFirstCompTarget = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompTargetNames: string[],\n): Promise<string[]> => {\n\tif (compTargetNames.length === 0) return [];\n\tconst firstCompTargetName = compTargetNames.slice(0, 1)[0];\n\n\tconst dstContractPath = getOutputContractFilename(parsedArgs, sourceFile);\n\tawait copyFile(\n\t\tjoin(\n\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\tfirstCompTargetName,\n\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_contract.json' : 'step_000_cont_0_contract.tz',\n\t\t),\n\t\tdstContractPath,\n\t);\n\n\tconst dstDefaultStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, firstCompTargetName, true);\n\tawait copyFile(\n\t\tjoin(\n\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\tfirstCompTargetName,\n\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_storage.json' : 'step_000_cont_0_storage.tz',\n\t\t),\n\t\tdstDefaultStoragePath,\n\t);\n\n\treturn [dstContractPath, dstDefaultStoragePath];\n};\n\nconst copyArtifactsForRestCompTargets = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\tcompTargetNames: string[],\n): Promise<string[]> => {\n\tif (compTargetNames.length === 0) return [];\n\tconst restCompTargetNames = compTargetNames.slice(1, compTargetNames.length);\n\n\tconst dstStoragePaths = await Promise.all(restCompTargetNames.map(async compTargetName => {\n\t\tconst dstStoragePath = getOutputStorageFilename(parsedArgs, sourceFile, compTargetName, false);\n\t\tawait copyFile(\n\t\t\tjoin(\n\t\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\t\tcompTargetName,\n\t\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_cont_0_storage.json' : 'step_000_cont_0_storage.tz',\n\t\t\t),\n\t\t\tdstStoragePath,\n\t\t);\n\t\treturn dstStoragePath;\n\t}));\n\n\treturn dstStoragePaths;\n};\n\nconst copyArtifactsForExprCompTargets = async (\n\tparsedArgs: Opts,\n\tsourceFile: string,\n\texprCompTargetNames: string[],\n): Promise<string[]> => {\n\tif (exprCompTargetNames.length === 0) return [];\n\n\tconst dstExprPaths = await Promise.all(exprCompTargetNames.map(async compTargetName => {\n\t\tconst dstExprPath = getOutputExprFilename(parsedArgs, sourceFile, compTargetName);\n\t\tawait copyFile(\n\t\t\tjoin(\n\t\t\t\tgetCompilationTargetsDirname(parsedArgs, sourceFile),\n\t\t\t\tcompTargetName,\n\t\t\t\tisOutputFormatJSON(parsedArgs) ? 'step_000_expression.json' : 'step_000_expression.tz',\n\t\t\t),\n\t\t\tdstExprPath,\n\t\t);\n\t\treturn dstExprPath;\n\t}));\n\n\treturn dstExprPaths;\n};\n\nconst copyRelevantArtifactsForCompTargets = (parsedArgs: Opts, sourceFile: string) =>\nasync (\n\t{ compTargetNames, exprCompTargetNames }: { compTargetNames: string[]; exprCompTargetNames: string[] },\n): Promise<string> => {\n\tif (compTargetNames.length === 0 && exprCompTargetNames.length === 0) return 'No compilation targets defined';\n\n\tconst dstContractAndDefaultStoragePaths = await copyArtifactsForFirstCompTarget(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\tcompTargetNames,\n\t);\n\n\tconst dstStoragePaths = await copyArtifactsForRestCompTargets(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\tcompTargetNames,\n\t);\n\n\tconst dstExpressionPaths = await copyArtifactsForExprCompTargets(\n\t\tparsedArgs,\n\t\tsourceFile,\n\t\texprCompTargetNames,\n\t);\n\n\treturn dstContractAndDefaultStoragePaths.concat(dstStoragePaths).concat(dstExpressionPaths).join('\\n');\n};\n\nconst getCompileContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);\n\tconst booleanFlags = ' --html --purge ';\n\treturn `${getSmartPyCli()} compile ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;\n};\n\nexport const compileContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir))\n\t\t.then(() => getCompileContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t})\n\t\t.then(() => getCompilationTargetNames(parsedArgs, sourceFile))\n\t\t.then(copyRelevantArtifactsForCompTargets(parsedArgs, sourceFile))\n\t\t.then(relevantArtifacts => ({\n\t\t\tcontract: sourceFile,\n\t\t\tartifact: relevantArtifacts,\n\t\t}))\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t});\n\nconst compile = (parsedArgs: Opts): Promise<void> =>\n\tcompileContract(parsedArgs, addPyExtensionIfMissing(parsedArgs.sourceFile))\n\t\t.then(result => [result])\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendAsyncErr(err, false));\n\nexport default compile;\n","import { execCmd, getArtifactsDir, getContractsDir, sendErr, sendWarn } from '@taqueria/node-sdk';\nimport { ProxyTaskArgs } from '@taqueria/node-sdk/types';\nimport { access, copyFile, readdir, stat } from 'fs/promises';\nimport { join } from 'path';\n\nexport interface CompileOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n\tjson: boolean;\n}\n\nexport interface CompileAllOpts extends ProxyTaskArgs.t {\n\tjson: boolean;\n}\n\nexport interface TestOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n}\n\nexport type IntersectionOpts = CompileOpts & CompileAllOpts & TestOpts;\n\ntype UnionOpts = CompileOpts | CompileAllOpts | TestOpts;\n\n// Should point to the latest stable version, so it needs to be updated as part of our release process.\nconst SMARTPY_DEFAULT_VERSION = 'v0.16.0';\n\nconst SMARTPY_VERSION_ENV_VAR = 'TAQ_SMARTPY_VERSION';\n\nconst SMARTPY_ARTIFACTS_DIR = '.smartpy';\n\nconst smartpyVersionToInstallerMap: { [k: string]: string } = {\n\t'v0.16.0': 'https://smartpy.io/releases/20221215-8f134ebb649f5a7b37c44fca8f336f970f523565/cli/install.sh',\n};\n\nconst getSmartpyVersion = (): string => {\n\tconst userDefinedSmartpyVersion = process.env[SMARTPY_VERSION_ENV_VAR];\n\tif (userDefinedSmartpyVersion) {\n\t\tif (/v0\\.1[4-6]\\./.test(userDefinedSmartpyVersion)) {\n\t\t\treturn userDefinedSmartpyVersion;\n\t\t} else {\n\t\t\tsendWarn(\n\t\t\t\t`Version ${userDefinedSmartpyVersion} is not supported by Taqueria yet. The supported versions are [${\n\t\t\t\t\tObject.keys(smartpyVersionToInstallerMap)\n\t\t\t\t}]. Will default to ${SMARTPY_DEFAULT_VERSION}`,\n\t\t\t);\n\t\t\treturn SMARTPY_DEFAULT_VERSION;\n\t\t}\n\t} else {\n\t\treturn SMARTPY_DEFAULT_VERSION;\n\t}\n};\n\nconst getPathToSmartPyCliDir = (): string => `${process.env.HOME}/smartpy-cli-${getSmartpyVersion()}`;\n\nexport const getSmartPyCli = (): string => `${getPathToSmartPyCliDir()}/SmartPy.sh`;\n\nconst getSmartPyInstallerCmd = (projectDir: string): string => {\n\tconst trimmedProjectdir = projectDir.replace(/\\/$/, '');\n\tconst installer = join(__dirname, 'install.sh');\n\tconst install = `bash ${installer} --yes --prefix ${getPathToSmartPyCliDir()} --project ${trimmedProjectdir};`;\n\treturn install;\n};\n\nexport const addPyExtensionIfMissing = (sourceFile: string): string =>\n\t/\\.py$/.test(sourceFile) ? sourceFile : `${sourceFile}.py`;\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.py$/);\n\treturn matchResult ? matchResult[0] : '';\n};\n\nconst removeExt = (path: string): string => {\n\tconst extRegex = new RegExp(extractExt(path));\n\treturn path.replace(extRegex, '');\n};\n\nexport const getInputFilename = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, getContractsDir(parsedArgs), sourceFile);\n\nexport const getCompilationTargetsDirname = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, getArtifactsDir(parsedArgs), SMARTPY_ARTIFACTS_DIR, removeExt(sourceFile));\n\nexport const installSmartPyCliIfNotExist = (projectDir: string) =>\n\taccess(getSmartPyCli())\n\t\t.catch(() => {\n\t\t\tsendWarn('SmartPy CLI not found. Installing it now...');\n\t\t\treturn execCmd(getSmartPyInstallerCmd(projectDir))\n\t\t\t\t.then(({ stderr }) => {\n\t\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\t});\n\t\t});\n\nexport const emitExternalError = (err: unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== Error messages for ${sourceFile} ===`);\n\terr instanceof Error ? sendErr(err.message.replace(/Command failed.+?\\n/, '')) : sendErr(err as any);\n\tsendErr(`\\n===`);\n};\n","import { getContractsDir, sendAsyncErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { CompileAllOpts as Opts, CompileOpts, getInputFilename } from './common';\nimport { compileContract, TableRow } from './compile';\n\nconst contractHasCompTarget = (parsedArgs: Opts, contactFilename: string): Promise<boolean> =>\n\treadFile(getInputFilename(parsedArgs, contactFilename), 'utf8')\n\t\t.then(data => /add_(expression_)?compilation_target\\s*\\(\\s*['\"][^'\"]+['\"]/.test(data));\n\nconst compileAll = async (parsedArgs: Opts): Promise<void> => {\n\tlet p: Promise<TableRow>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.py'],\n\t\t{ cwd: join(parsedArgs.config.projectDir, getContractsDir(parsedArgs)), absolute: false },\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (await contractHasCompTarget(parsedArgs, filename)) {\n\t\t\tp.push(compileContract(parsedArgs as CompileOpts, filename));\n\t\t}\n\t}\n\n\treturn Promise.all(p).then(sendJsonRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default compileAll;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport {\n\taddPyExtensionIfMissing,\n\temitExternalError,\n\tgetCompilationTargetsDirname,\n\tgetInputFilename,\n\tgetSmartPyCli,\n\tinstallSmartPyCliIfNotExist,\n\tTestOpts as Opts,\n} from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\tconst outputDir = getCompilationTargetsDirname(parsedArgs, sourceFile);\n\tconst booleanFlags = ' --html --purge ';\n\treturn `${getSmartPyCli()} test ${getInputFilename(parsedArgs, sourceFile)} ${outputDir} ${booleanFlags}`;\n};\n\nconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\tgetArch()\n\t\t.then(() => installSmartPyCliIfNotExist(parsedArgs.projectDir))\n\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t.then(execCmd)\n\t\t.then(({ stdout, stderr }) => {\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t};\n\t\t})\n\t\t.catch(err => {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tcontract: sourceFile,\n\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t};\n\t\t});\n\nconst test = (parsedArgs: Opts): Promise<void> => {\n\tconst sourceFile = addPyExtensionIfMissing(parsedArgs.sourceFile);\n\treturn testContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>\n\t\tsendAsyncErr(err, false)\n\t);\n};\n\nexport default test;\n"],"mappings":";AAAA,SAAS,QAAQ,QAAQ,YAAY;;;ACArC,SAAsB,gBAAAA,qBAAoB;;;ACA1C,SAAS,WAAAC,UAAS,SAAS,mBAAAC,kBAAiB,cAAc,aAAa,YAAAC,iBAAgB;AACvF,SAAS,YAAAC,WAAU,gBAAgB;AACnC,SAAS,UAAU,SAAS,QAAAC,aAAY;;;ACFxC,SAAS,SAAS,iBAAiB,iBAAiB,SAAS,gBAAgB;AAE7E,SAAS,cAAuC;AAChD,SAAS,YAAY;AAoBrB,IAAM,0BAA0B;AAEhC,IAAM,0BAA0B;AAEhC,IAAM,wBAAwB;AAE9B,IAAM,+BAAwD;AAAA,EAC7D,WAAW;AACZ;AAEA,IAAM,oBAAoB,MAAc;AACvC,QAAM,4BAA4B,QAAQ,IAAI,uBAAuB;AACrE,MAAI,2BAA2B;AAC9B,QAAI,eAAe,KAAK,yBAAyB,GAAG;AACnD,aAAO;AAAA,IACR,OAAO;AACN;AAAA,QACC,WAAW,yBAAyB,kEACnC,OAAO,KAAK,4BAA4B,CACzC,sBAAsB,uBAAuB;AAAA,MAC9C;AACA,aAAO;AAAA,IACR;AAAA,EACD,OAAO;AACN,WAAO;AAAA,EACR;AACD;AAEA,IAAM,yBAAyB,MAAc,GAAG,QAAQ,IAAI,IAAI,gBAAgB,kBAAkB,CAAC;AAE5F,IAAM,gBAAgB,MAAc,GAAG,uBAAuB,CAAC;AAEtE,IAAM,yBAAyB,CAAC,eAA+B;AAC9D,QAAM,oBAAoB,WAAW,QAAQ,OAAO,EAAE;AACtD,QAAM,YAAY,KAAK,WAAW,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C;AAAA,MACD,SAAS;AAAA,MACT,UAAU;AAAA,MACV,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,SAAS;AAAA,UACT,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,IACD,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS;AAAA,MACT,UAAU;AAAA,IACX,CAAC;AAAA,EACF;AAAA,EACA,OAAO;AACR,IAAI,QAAQ,IAAI;","names":["sendAsyncErr","execCmd","getArtifactsDir","sendWarn","copyFile","join","join","getArtifactsDir","copyFile","execCmd","sendWarn","getContractsDir","sendAsyncErr","sendJsonRes","readFile","join","readFile","join","getContractsDir","sendJsonRes","sendAsyncErr","execCmd","getArch","sendAsyncErr","sendJsonRes","sendWarn","getArch","execCmd","sendWarn","sendJsonRes","sendAsyncErr","sendAsyncErr"]}
|
package/package.json
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
2
|
+
"name": "@taqueria/plugin-smartpy-legacy",
|
|
3
|
+
"version": "0.57.9",
|
|
4
|
+
"description": "A taqueria plugin for compiling SmartPy smart contracts using SmartPy v0.16 (legacy syntax).",
|
|
5
|
+
"targets": {
|
|
6
|
+
"default": {
|
|
7
|
+
"source": "./index.ts",
|
|
8
|
+
"distDir": "./",
|
|
9
|
+
"context": "node",
|
|
10
|
+
"isLibrary": true
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.d.ts",
|
|
15
|
+
"index.js",
|
|
16
|
+
"index.js.map",
|
|
17
|
+
"index.mjs",
|
|
18
|
+
"index.mjs.map",
|
|
19
|
+
"install.sh",
|
|
20
|
+
"README.md",
|
|
21
|
+
"smartpy-v0.16.0"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"taqueria",
|
|
25
|
+
"tezos",
|
|
26
|
+
"build",
|
|
27
|
+
"pinnaclelabs",
|
|
28
|
+
"pinnacle-labs",
|
|
29
|
+
"plugin",
|
|
30
|
+
"smartpy",
|
|
31
|
+
"smart contract",
|
|
32
|
+
"compile"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=16.0"
|
|
36
|
+
},
|
|
37
|
+
"author": "Taqueria",
|
|
38
|
+
"license": "Apache-2.0",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/tezostaqueria/taqueria.git",
|
|
42
|
+
"directory": "taqueria-plugin-smartpy-legacy"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/tezostaqueria/taqueria/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/tezostaqueria/taqueria#readme",
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"fast-glob": "^3.3.2",
|
|
50
|
+
"@taqueria/node-sdk": "0.57.9"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"tsup": "^8.0.1",
|
|
54
|
+
"typescript": "^5.3.3"
|
|
55
|
+
},
|
|
56
|
+
"tsup": {
|
|
57
|
+
"entry": [
|
|
58
|
+
"index.ts"
|
|
59
|
+
],
|
|
60
|
+
"sourcemap": true,
|
|
61
|
+
"target": "node16",
|
|
62
|
+
"outDir": "./",
|
|
63
|
+
"dts": true,
|
|
64
|
+
"clean": false,
|
|
65
|
+
"skipNodeModulesBundle": true,
|
|
66
|
+
"platform": "node",
|
|
67
|
+
"format": [
|
|
68
|
+
"esm",
|
|
69
|
+
"cjs"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "ff58a2fc06ad233869ad6be574093c8b3b272e2e",
|
|
73
|
+
"scripts": {
|
|
74
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
75
|
+
"build": "npx tsc -noEmit -p ./tsconfig.json && npx tsup",
|
|
76
|
+
"pluginInfo": "npx ts-node index.ts --taqRun pluginInfo --i18n {\"foo:\"\"bar\"}"
|
|
77
|
+
}
|
|
78
|
+
}
|