@taqueria/lib-ligo 0.40.10
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/LICENSE +201 -0
- package/README.md +5 -0
- package/common.ts +67 -0
- package/compile-all.ts +34 -0
- package/compile.ts +478 -0
- package/createContract.ts +38 -0
- package/index.d.ts +2 -0
- package/index.js +728 -0
- package/index.js.map +1 -0
- package/index.mjs +700 -0
- package/index.mjs.map +1 -0
- package/index.ts +121 -0
- package/ligo.ts +73 -0
- package/ligo_templates.ts +31 -0
- package/main.ts +27 -0
- package/package.json +68 -0
- package/postinstall.js +19 -0
- package/test.ts +55 -0
- package/tsconfig.json +103 -0
package/index.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts","createContract.ts","ligo_templates.ts","main.ts","common.ts","compile.ts","compile-all.ts","ligo.ts","test.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport * as PluginSchema from '@taqueria/protocol/PluginSchema';\n\nimport createContract from './createContract';\nimport main from './main';\n\ntype PluginConfigurator = (plugin: PluginSchema.RawPluginSchema) => PluginSchema.RawPluginSchema;\ntype ConfiguratorArgs = {\n\tname: string\n\talias: string\n\tconfigurator?: PluginConfigurator\n\tunparsedArgs: string[]\n\tdockerImage: string\n\tdockerImageEnvVar: string\n}\n\nexport const configurePlugin = (settings: ConfiguratorArgs) => {\n\tconst schema = {\n\t\tname: settings.name,\n\t\tschema: '1.0',\n\t\tversion: '0.1',\n\t\talias: settings.alias,\n\t\ttasks: [\n\t\t\tTask.create({\n\t\t\t\ttask: 'ligo',\n\t\t\t\tcommand: 'ligo',\n\t\t\t\tdescription:\n\t\t\t\t\t'This task allows you to run arbitrary LIGO native commands. Note that they might not benefit from the abstractions provided by Taqueria',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tshortFlag: 'c',\n\t\t\t\t\t\tflag: 'command',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The command to be passed to the underlying LIGO binary, wrapped in quotes',\n\t\t\t\t\t\trequired: true,\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'none',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'compile',\n\t\t\t\tcommand: 'compile <sourceFile>',\n\t\t\t\taliases: ['c', 'compile-ligo'],\n\t\t\t\tdescription:\n\t\t\t\t\t'Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storage/parameter list files if they are found',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'json',\n\t\t\t\t\t\tboolean: true,\n\t\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t\t}),\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'module',\n\t\t\t\t\t\tshortFlag: 'm',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The LIGO module to be compiled',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'compile-all',\n\t\t\t\tcommand: 'compile-all',\n\t\t\t\tdescription:\n\t\t\t\t\t'Compile all main smart contracts written in a LIGO syntax to Michelson code, along with their associated storage/parameter list files if they are found',\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tflag: 'json',\n\t\t\t\t\t\tboolean: true,\n\t\t\t\t\t\tdescription: 'Emit JSON-encoded Michelson',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'test',\n\t\t\t\tcommand: 'test <sourceFile>',\n\t\t\t\tdescription: 'Test a smart contract written in LIGO',\n\t\t\t\thandler: 'proxy',\n\t\t\t\tencoding: 'json',\n\t\t\t}),\n\t\t\tTask.create({\n\t\t\t\ttask: 'get-image',\n\t\t\t\tcommand: 'get-image',\n\t\t\t\tdescription: 'Gets the name of the image to be used',\n\t\t\t\thandler: 'proxy',\n\t\t\t\thidden: true,\n\t\t\t}),\n\t\t],\n\t\ttemplates: [\n\t\t\tTemplate.create({\n\t\t\t\ttemplate: 'contract',\n\t\t\t\tcommand: 'contract <sourceFileName>',\n\t\t\t\tdescription: 'Create a LIGO contract with boilerplate code',\n\t\t\t\tpositionals: [\n\t\t\t\t\tPositionalArg.create({\n\t\t\t\t\t\tplaceholder: 'sourceFileName',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The name of the LIGO contract to generate',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\toptions: [\n\t\t\t\t\tOption.create({\n\t\t\t\t\t\tshortFlag: 's',\n\t\t\t\t\t\tflag: 'syntax',\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t\tdescription: 'The syntax used in the contract',\n\t\t\t\t\t}),\n\t\t\t\t],\n\t\t\t\thandler: createContract,\n\t\t\t}),\n\t\t],\n\t\tproxy: main(settings.dockerImage, settings.dockerImageEnvVar),\n\t\tpostInstall: `node ${__dirname}/postinstall.js`,\n\t}\n\n\treturn Plugin.create(() => settings.configurator ? settings.configurator(schema) : schema, settings.unparsedArgs);\n}\n","import { sendAsyncErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk';\nimport { writeFile } from 'fs/promises';\nimport { jsligo_template, mligo_template } from './ligo_templates';\n\ninterface Opts extends RequestArgs.t {\n\tsourceFileName?: string;\n\tsyntax?: string;\n}\n\nconst getLigoTemplate = async (contractName: string, syntax: string | undefined): Promise<string> => {\n\tconst matchResult = contractName.match(/\\.[^.]+$/);\n\tconst ext = matchResult ? matchResult[0].substring(1) : null;\n\n\tif (syntax === 'mligo') return mligo_template;\n\tif (syntax === 'jsligo') return jsligo_template;\n\n\tif (syntax === undefined) {\n\t\tif (ext === 'mligo') return mligo_template;\n\t\tif (ext === 'jsligo') return jsligo_template;\n\t\treturn sendAsyncErr(\n\t\t\t`Unable to infer LIGO syntax from \"${contractName}\". Please specify a LIGO syntax via the --syntax option`,\n\t\t);\n\t} else {\n\t\treturn sendAsyncErr(`\"${syntax}\" is not a valid syntax. Please specify a valid LIGO syntax`);\n\t}\n};\n\nconst createContract = (args: RequestArgs.t) => {\n\tconst unsafeOpts = args as unknown as Opts;\n\tconst contractName = unsafeOpts.sourceFileName as string;\n\tconst syntax = unsafeOpts.syntax;\n\tconst contractsDir = `${args.config.projectDir}/${args.config.contractsDir}`;\n\treturn getLigoTemplate(contractName, syntax)\n\t\t.then(ligo_template => writeFile(`${contractsDir}/${contractName}`, ligo_template));\n};\n\nexport default createContract;\n","export const mligo_template = `\ntype storage = int\ntype return = operation list * storage\n\n(* Three entrypoints *)\n[@entry] let increment (delta : int) (store : storage) : return =\n [], store + delta\n[@entry] let decrement (delta : int) (store : storage) : return =\n [], store - delta\n[@entry] let reset (() : unit) (_ : storage) : return =\n [], 0\n`;\n\n\nexport const jsligo_template = `\ntype storage = int;\ntype ret = [list<operation>, storage];\n\n// Three entrypoints\n\n// @entry\nconst increment = (delta : int, store : storage) : ret =>\n [list([]), store + delta];\n\n// @entry\nconst decrement = (delta : int, store : storage) : ret =>\n [list([]), store - delta];\n\n// @entry\nconst reset = (_ : unit, _ : storage) : ret =>\n [list([]), 0];\n`;\n","import { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { configure, IntersectionOpts as Opts } from './common';\nimport compile from './compile';\nimport compileAll from './compile-all';\nimport ligo from './ligo';\nimport test from './test';\n\nconst main = (dockerImage: string, dockerImageEnvVar: string) => (parsedArgs: RequestArgs.t): Promise<void> => {\n\tconst commonObj = configure(dockerImage, dockerImageEnvVar);\n\tconst unsafeOpts = parsedArgs as unknown as Opts;\n\tswitch (unsafeOpts.task) {\n\t\tcase 'ligo':\n\t\t\treturn ligo(commonObj, unsafeOpts);\n\t\tcase 'compile':\n\t\t\treturn compile(commonObj, unsafeOpts);\n\t\tcase 'compile-all':\n\t\t\treturn compileAll(commonObj, unsafeOpts);\n\t\tcase 'test':\n\t\t\treturn test(commonObj, parsedArgs);\n\t\tcase 'get-image':\n\t\t\treturn sendAsyncRes(commonObj.getLigoDockerImage());\n\t\tdefault:\n\t\t\treturn sendAsyncErr(`${unsafeOpts.task} is not an understood task by the LIGO plugin`);\n\t}\n};\n\nexport default main;\n","import { getDockerImage, sendErr } from '@taqueria/node-sdk';\nimport { ProxyTaskArgs, RequestArgs } from '@taqueria/node-sdk/types';\nimport { join } from 'path';\n\nexport interface LigoOpts extends ProxyTaskArgs.t {\n\tcommand: string;\n}\n\nexport interface CompileOpts extends ProxyTaskArgs.t {\n\tsourceFile: string;\n\tjson: boolean;\n\tmodule?: string;\n}\n\nexport interface CompileAllOpts extends ProxyTaskArgs.t {\n\tjson: boolean;\n}\n\nexport interface TestOpts extends RequestArgs.t {\n\ttask?: string;\n\tsourceFile?: string;\n}\n\nexport type IntersectionOpts = LigoOpts & CompileOpts & CompileAllOpts & TestOpts;\n\nexport type UnionOpts = LigoOpts | CompileOpts | CompileAllOpts | TestOpts;\n\nexport const getInputFilenameAbsPath = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? 'contracts', sourceFile);\n\nexport const getInputFilenameRelPath = (parsedArgs: UnionOpts, sourceFile: string): string =>\n\tjoin(parsedArgs.config.contractsDir ?? 'contracts', sourceFile);\n\nexport const formatLigoError = (err: Error): Error => {\n\tlet result = err.message.replace(/Command failed.+?\\n/, '');\n\tif (\n\t\tresult.includes('An internal error ocurred. Please, contact the developers.')\n\t\t&& result.includes('Module Contract not found with last Contract.')\n\t) {\n\t\tresult =\n\t\t\t`By convention, Taqueria expects you to import your contract with Contract as the module name.\\nFor instance, if you have a contract in a file called \"increment.mligo\", in your parameter/storage list file you must include #import \"Increment.mligo\" \"Contract\" for compilation to be successful.`;\n\t}\n\n\terr.message = result.replace(\n\t\t'An internal error ocurred. Please, contact the developers.',\n\t\t'The LIGO compiler experienced an internal error. Please contact the LIGO developers.',\n\t);\n\n\treturn err;\n};\n\nexport const emitExternalError = (errs: unknown[] | unknown, sourceFile: string): void => {\n\tsendErr(`\\n=== Error messages for ${sourceFile} ===`);\n\tconst errors = Array.isArray(errs) ? errs : [errs];\n\terrors.map(err => {\n\t\terr instanceof Error ? sendErr(err.message) : sendErr(err as any);\n\t});\n\tsendErr(`===`);\n};\n\nexport const configure = (dockerImage: string, dockerImageEnvVar: string) => ({\n\tLIGO_DEFAULT_IMAGE: dockerImage,\n\tLIGO_IMAGE_ENV_VAR: dockerImageEnvVar,\n\tgetLigoDockerImage: () => getDockerImage(dockerImage, dockerImageEnvVar)\n})\n\nexport type Common = ReturnType<typeof configure>;\n","import {\n\texecCmd,\n\tgetArch,\n\tgetArtifactsDir,\n\tsendAsyncErr,\n\tsendErr,\n\tsendJsonRes,\n\tsendRes,\n\tsendWarn,\n} from '@taqueria/node-sdk';\nimport { createReadStream } from 'fs';\nimport { access, readFile, writeFile } from 'fs/promises';\nimport { basename, extname, join } from 'path';\nimport * as readline from 'readline';\nimport {\n\tCompileOpts as Opts,\n\temitExternalError,\n\tformatLigoError,\n\tgetInputFilenameAbsPath,\n\tgetInputFilenameRelPath,\n\tCommon,\n\tUnionOpts,\n\tconfigure\n} from './common';\n\nexport type TableRow = { source: string; artifact: string; err?: unknown };\n\nexport type ExprKind = 'storage' | 'default_storage' | 'parameter';\n\nexport type Syntax = 'mligo' | 'jsligo' | 'religo' | 'ligo';\n\nexport type ModuleInfo = {\n\tmoduleName: string;\n\tsourceName: string;\n\tsourceFile: string;\n\tsyntax: Syntax;\n\ttype: 'file-main' | 'file-entry' | 'module-main' | 'module-entry';\n};\n\nconst COMPILE_ERR_MSG: string = 'Not compiled';\n\nconst isStorageKind = (exprKind: ExprKind): boolean => exprKind === 'storage' || exprKind === 'default_storage';\n\nexport const isSupportedLigoSyntax = (sourceFile: string) => /\\.(mligo|jsligo)$/.test(sourceFile);\n\nexport const isUnsupportedLigoSyntax = (sourceFile: string) => /\\.(ligo|religo)$/.test(sourceFile);\n\nexport const isLIGOFile = (sourceFile: string) =>\n\tisSupportedLigoSyntax(sourceFile) || isUnsupportedLigoSyntax(sourceFile);\n\nexport const isStorageListFile = (sourceFile: string): boolean =>\n\t/.+\\.(storageList|storages)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\nexport const isParameterListFile = (sourceFile: string): boolean =>\n\t/.+\\.(parameterList|parameters)\\.(ligo|religo|mligo|jsligo)$/.test(sourceFile);\n\n\n\nconst extractExt = (path: string): string => {\n\tconst matchResult = path.match(/\\.(ligo|religo|mligo|jsligo)$/);\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\nconst isOutputFormatJSON = (parsedArgs: Opts): boolean => parsedArgs.json;\n\nconst getOutputContractFilename = (parsedArgs: Opts, module: ModuleInfo): string => {\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\treturn join(getArtifactsDir(parsedArgs), `${module.moduleName}${ext}`);\n};\n\nconst getOutputExprFilename = (parsedArgs: Opts, module: ModuleInfo, exprKind: ExprKind, exprName: string): string => {\n\tconst contractName = module.moduleName;\n\tconst ext = isOutputFormatJSON(parsedArgs) ? '.json' : '.tz';\n\tconst outputFile = exprKind === 'default_storage'\n\t\t? `${contractName}.default_storage${ext}`\n\t\t: `${contractName}.${exprKind}.${exprName}${ext}`;\n\treturn join(getArtifactsDir(parsedArgs), `${outputFile}`);\n};\n\nconst getExprNames = (parsedArgs: Opts, sourceFile: string): Promise<string[]> => {\n\treturn new Promise((resolve, reject) => {\n\t\tconst inputFilePath = getInputFilenameAbsPath(parsedArgs, sourceFile);\n\t\tconst readInterface = readline.createInterface({\n\t\t\tinput: createReadStream(inputFilePath),\n\t\t\toutput: process.stdout,\n\t\t});\n\n\t\tconst variableNames: string[] = [];\n\n\t\treadInterface.on('line', function(line) {\n\t\t\t// Skip lines that start with a comment\n\t\t\tif (!line.trim().startsWith('//')) {\n\t\t\t\tconst matches = line.match(/(?<=\\s*(let|const)\\s+)[a-zA-Z0-9_]+/g);\n\t\t\t\tif (matches) {\n\t\t\t\t\tvariableNames.push(...matches);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\treadInterface.on('close', function() {\n\t\t\tresolve(variableNames);\n\t\t});\n\t});\n};\n\n// Helper function to get the initial message based on the pair value\nconst getInitialMessage = (pair: string, module: ModuleInfo) => {\n\tconst messages = {\n\t\t'mligo-file-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was not within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-file-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was not within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-module-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'mligo-module-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was within a named module. As such, the examples below are written with that assumption in mind.`,\n\t\t'jsligo-file-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was not within a namespace. As such, the examples below are written with that assumption in mind.\\n`\n\t\t\t+ `// NOTE: The \"storage\" type should be exported from the contract file (${module.sourceFile})`,\n\t\t'jsligo-file-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was not within a namespace. As such, the examples below are written with that assumption in mind.`,\n\t\t'jsligo-module-main':\n\t\t\t`// When this file was created, the smart contract was defined with a main function that was within a namespace. As such, the examples below are written with that assumption in mind.\\n`\n\t\t\t+ `// NOTE: The \"storage\" type should be exported from the contract file (${module.sourceFile})`,\n\t\t'jsligo-module-entry':\n\t\t\t`// When this file was created, the smart contract was defined with an entrypoint using \\`@entry\\` that was within a namespace. As such, the examples below are written with that assumption in mind.`,\n\t\t// ... any other combinations\n\t} as Record<string, string>;\n\n\treturn messages[pair] || '// This file was created by Taqueria.';\n};\n\n// Helper function to get a common message\nconst getCommonMsg = (langType: Syntax, listType: ExprKind) => {\n\tconst varKeyword = langType === 'mligo' ? 'let' : 'const';\n\tconst commonMsgForStorage = `// IMPORTANT: We suggest always explicitly typing your storage values:\\n`\n\t\t+ `// E.g.: \\`${varKeyword} storage: int = 10\\` or \\`${varKeyword} storage: Contract.storage = 10\\``;\n\n\tconst commonMsgForParameter = `// IMPORTANT: We suggest always explicitly typing your parameter values:\\n`\n\t\t+ `// E.g.: \\`${varKeyword} parameter: int = 10\\` or \\`${varKeyword} parameter: Contract.parameter = 10\\``;\n\n\treturn listType === 'storage' ? commonMsgForStorage : commonMsgForParameter;\n};\n\n// Main function to get the content for storage or parameter\nconst getContent = (moduleInfo: ModuleInfo, listType: ExprKind) => {\n\tconst linkToContract = `#import \"${moduleInfo.sourceFile}\" \"Contract\"`;\n\tconst pair = `${moduleInfo.syntax}-${moduleInfo.type}`;\n\tconst initialMsg = getInitialMessage(pair, moduleInfo);\n\tconst commonMsg = getCommonMsg(moduleInfo.syntax, listType);\n\n\treturn `${linkToContract}\\n\\n${initialMsg}\\n\\n${commonMsg}`;\n};\n\n// Usage for storage list\nconst initContentForStorage = (moduleInfo: ModuleInfo) => getContent(moduleInfo, 'storage');\n\n// Usage for parameter list\nconst initContentForParameter = (moduleInfo: ModuleInfo) => getContent(moduleInfo, 'parameter');\n\n// Inject commonObj to return some functions\nexport const inject = (commonObj: Common) => {\n\tconst {getLigoDockerImage} = commonObj;\n\n\tconst getListDeclarationsCmd = async (parsedArgs: UnionOpts, sourceFile: string): Promise<string> => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} info list-declarations`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst flags = '--display-format json';\n\t\tconst cmd = `${baseCmd} ${inputFile} ${flags}`;\n\t\treturn cmd;\n\t};\n\n\tconst listContractModules = async (parsedArgs: UnionOpts, sourceFile: string): Promise<ModuleInfo[]> => {\n\t\ttry {\n\t\t\tawait getArch();\n\t\t\tconst cmd = await getListDeclarationsCmd(parsedArgs, sourceFile);\n\t\t\tconst { stderr, stdout } = await execCmd(cmd);\n\t\t\tif (stderr.length > 0) return Promise.reject(stderr);\n\t\n\t\t\treturn JSON.parse(stdout).declarations.reduce(\n\t\t\t\t(acc: ModuleInfo[], decl: string) => {\n\t\t\t\t\t// We need to process delcarations (decl) like so:\n\t\t\t\t\t// 1. If the decl is equal to the string \"main\", then the module type is \"file-main\" and the name of the module is the sourceFile.\n\t\t\t\t\t// 2. If the decl is equal to $main, then the module type is \"file-entry\" and the name fo the module is the sourceFile.\n\t\t\t\t\t// 3. If the decl ends with .main, then the module type is \"module-main\" and the name of the module is the decl without the .main suffix.\n\t\t\t\t\t// 4. If the decl ends with .$main, then the module type is \"module-entry\" and the name of the module is the decl without the .$main suffix.\n\t\t\t\t\t// Otherwise, this is not a declaration we care about.\n\t\t\t\t\tconst srcFile = removeExt(basename(sourceFile));\n\t\t\t\t\tconst syntax = extractExt(sourceFile).replace('.', '');\n\t\n\t\t\t\t\tif (decl === 'main') {\n\t\t\t\t\t\treturn [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: 'file-main', syntax }];\n\t\t\t\t\t} else if (decl === '$main') {\n\t\t\t\t\t\treturn [...acc, { moduleName: srcFile, sourceName: sourceFile, sourceFile, type: 'file-entry', syntax }];\n\t\t\t\t\t} else if (decl.endsWith('.main')) {\n\t\t\t\t\t\tconst moduleName = decl.replace(/\\.main$/, '');\n\t\t\t\t\t\treturn [...acc, {\n\t\t\t\t\t\t\tmoduleName,\n\t\t\t\t\t\t\tsourceName: `${sourceFile}/${moduleName}`,\n\t\t\t\t\t\t\tsourceFile,\n\t\t\t\t\t\t\ttype: 'module-main',\n\t\t\t\t\t\t\tsyntax,\n\t\t\t\t\t\t}];\n\t\t\t\t\t} else if (decl.endsWith('.$main')) {\n\t\t\t\t\t\tconst moduleName = decl.replace(/\\.\\$main$/, '');\n\t\t\t\t\t\treturn [...acc, {\n\t\t\t\t\t\t\tmoduleName,\n\t\t\t\t\t\t\tsourceName: `${sourceFile}/${moduleName}`,\n\t\t\t\t\t\t\tsourceFile,\n\t\t\t\t\t\t\ttype: 'module-entry',\n\t\t\t\t\t\t\tsyntax,\n\t\t\t\t\t\t}];\n\t\t\t\t\t}\n\t\t\t\t\treturn acc;\n\t\t\t\t},\n\t\t\t\t[],\n\t\t\t);\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [];\n\t\t}\n\t};\n\n\tconst getCompileContractCmd = async (parsedArgs: Opts, sourceFile: string, module: ModuleInfo): Promise<string> => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile contract`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst outputFile = `-o ${getOutputContractFilename(parsedArgs, module)}`;\n\t\tconst flags = isOutputFormatJSON(parsedArgs) ? ' --michelson-format json ' : '';\n\t\tconst moduleFlag = module.type.startsWith('file-') ? '' : `-m ${module.moduleName}`;\n\t\tconst cmd = `${baseCmd} ${inputFile} ${outputFile} ${flags}${moduleFlag}`;\n\t\treturn cmd;\n\t};\n\n\tconst compileContract = async (parsedArgs: Opts, sourceFile: string, module: ModuleInfo): Promise<TableRow> => {\n\t\ttry {\n\t\t\tawait getArch();\n\t\t\tconst cmd = await getCompileContractCmd(parsedArgs, sourceFile, module);\n\t\t\tconst { stderr } = await execCmd(cmd);\n\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\n\t\t\treturn {\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: getOutputContractFilename(parsedArgs, module),\n\t\t\t};\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn {\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: COMPILE_ERR_MSG,\n\t\t\t};\n\t\t}\n\t};\n\t\n\tconst getCompileExprCmd = (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t\texprKind: ExprKind,\n\t\texprName: string,\n\t): string => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw new Error(`No project directory provided`);\n\t\tconst compilerType = isStorageKind(exprKind) ? 'storage' : 'parameter';\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} compile ${compilerType}`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst outputFile = `-o ${getOutputExprFilename(parsedArgs, module, exprKind, exprName)}`;\n\t\tconst flags = isOutputFormatJSON(parsedArgs) ? ' --michelson-format json ' : '';\n\t\n\t\t// Parameter and Storage list files are expected to import the smart contract file as the \"Contract\" module.\n\t\tconst moduleFlag = (() => {\n\t\t\tswitch (module.type) {\n\t\t\t\tcase 'file-main':\n\t\t\t\tcase 'file-entry':\n\t\t\t\t\treturn '-m Contract';\n\t\t\t\tdefault:\n\t\t\t\t\treturn `-m Contract.${module.moduleName}`;\n\t\t\t}\n\t\t})();\n\t\n\t\tconst cmd = `${baseCmd} ${inputFile} ${exprName} ${outputFile} ${flags} ${moduleFlag}`;\n\t\treturn cmd;\n\t};\n\n\tconst compileExpr =\n\t\t(parsedArgs: Opts, sourceFile: string, module: ModuleInfo, exprKind: ExprKind) =>\n\t\t(exprName: string): Promise<TableRow> => {\n\t\treturn getArch()\n\t\t\t.then(() => getCompileExprCmd(parsedArgs, sourceFile, module, exprKind, exprName))\n\t\t\t.then(execCmd)\n\t\t\t.then(({ stderr }) => {\n\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\tconst artifactName = getOutputExprFilename(parsedArgs, module, exprKind, exprName);\n\t\t\t\treturn {\n\t\t\t\t\tsource: module.sourceName,\n\t\t\t\t\tartifact: artifactName,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\treturn {\n\t\t\t\t\tsource: module.sourceName,\n\t\t\t\t\tartifact: `${exprName} in ${sourceFile} not compiled`,\n\t\t\t\t\terr,\n\t\t\t\t};\n\t\t\t});\n\t};\n\n\tconst compileExprs = async (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t\texprKind: ExprKind,\n\t): Promise<TableRow[]> => {\n\t\t// Get expressions from file\n\t\tlet exprs = [];\n\t\ttry {\n\t\t\texprs = await getExprNames(parsedArgs, sourceFile);\n\t\t} catch (err) {\n\t\t\temitExternalError(err, sourceFile);\n\t\t\treturn [{\n\t\t\t\tsource: module.sourceName,\n\t\t\t\tartifact: `No ${isStorageKind(exprKind) ? 'storage' : 'parameter'} expressions compiled`,\n\t\t\t}];\n\t\t}\n\t\n\t\tconst results = await Promise.all(exprs.map(async (exprName, index) => {\n\t\t\tconst compileResult = await compileExpr(\n\t\t\t\tparsedArgs,\n\t\t\t\tsourceFile,\n\t\t\t\tmodule,\n\t\t\t\texprKind === 'storage' && index === 0 ? 'default_storage' : exprKind,\n\t\t\t)(exprName);\n\t\t\treturn compileResult;\n\t\t}));\n\t\n\t\t// Collect errors\n\t\tconst errors = results.reduce(\n\t\t\t(acc, result) => {\n\t\t\t\tif (result.err) {\n\t\t\t\t\t// If its not an Error object, then just add it to the list\n\t\t\t\t\tif (!(result.err instanceof Error)) return [...acc, result.err];\n\t\n\t\t\t\t\t// Otherwise, get all ligo errors and ensure that the list is unique\n\t\t\t\t\tconst ligoErrs = (acc\n\t\t\t\t\t\t.filter(err => err instanceof Error) as Error[])\n\t\t\t\t\t\t.map(err => err.message);\n\t\n\t\t\t\t\tconst formattedError = formatLigoError(result.err);\n\t\n\t\t\t\t\treturn (ligoErrs.includes(formattedError.message)) ? acc : [...acc, formattedError];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t[] as unknown[],\n\t\t);\n\t\n\t\t// Collect table rows\n\t\tconst retval = results.map(({ source, artifact }) => ({ source, artifact }));\n\t\n\t\tif (errors.length) emitExternalError(errors, sourceFile);\n\t\n\t\treturn retval;\n\t};\n\n\tconst compileContractWithStorageAndParameter = async (\n\t\tparsedArgs: Opts,\n\t\tsourceFile: string,\n\t\tmodule: ModuleInfo,\n\t): Promise<TableRow[]> => {\n\t\tconst contractCompileResult = await compileContract(parsedArgs, sourceFile, module);\n\t\tif (contractCompileResult.artifact === COMPILE_ERR_MSG) return [contractCompileResult];\n\t\tdebugger;\n\t\n\t\tconst storageListFile = `${module.moduleName}.storageList${extractExt(sourceFile)}`;\n\t\tconst storageListFilename = getInputFilenameAbsPath(parsedArgs, storageListFile);\n\t\tconst storageCompileResult = await access(storageListFilename)\n\t\t\t.then(() => compileExprs(parsedArgs, storageListFile, module, 'storage'))\n\t\t\t.catch(() => {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`Note: storage file associated with \"${module.moduleName}\" can't be found, so \"${storageListFile}\" has been created for you. Use this file to define all initial storage values for this contract\\n`,\n\t\t\t\t);\n\t\t\t\treturn writeFile(storageListFilename, initContentForStorage(module), 'utf8');\n\t\t\t});\n\t\n\t\tconst parameterListFile = `${module.moduleName}.parameterList${extractExt(sourceFile)}`;\n\t\tconst parameterListFilename = getInputFilenameAbsPath(parsedArgs, parameterListFile);\n\t\tconst parameterCompileResult = await access(parameterListFilename)\n\t\t\t.then(() => compileExprs(parsedArgs, parameterListFile, module, 'parameter'))\n\t\t\t.catch(() => {\n\t\t\t\tsendWarn(\n\t\t\t\t\t`Note: parameter file associated with \"${module.moduleName}\" can't be found, so \"${parameterListFile}\" has been created for you. Use this file to define all parameter values for this contract\\n`,\n\t\t\t\t);\n\t\t\t\treturn writeFile(parameterListFilename, initContentForParameter(module), 'utf8');\n\t\t\t});\n\t\n\t\tconst storageArtifacts = storageCompileResult ? storageCompileResult.map(res => res.artifact).join('\\n') : '';\n\t\tconst parameterArtifacts = parameterCompileResult ? parameterCompileResult.map(res => res.artifact).join('\\n') : '';\n\t\n\t\tconst combinedArtifact = [\n\t\t\tcontractCompileResult.artifact,\n\t\t\tstorageArtifacts,\n\t\t\tparameterArtifacts,\n\t\t].filter(Boolean).join('\\n');\n\t\n\t\tconst combinedRow: TableRow = {\n\t\t\tsource: module.sourceName,\n\t\t\tartifact: combinedArtifact,\n\t\t};\n\t\n\t\treturn [combinedRow];\n\t};\n\n\treturn {\n\t\tgetLigoDockerImage,\n\t\tgetListDeclarationsCmd,\n\t\tlistContractModules,\n\t\tgetCompileContractCmd,\n\t\tcompileContract,\n\t\tgetCompileExprCmd,\n\t\tcompileExpr,\n\t\tcompileExprs,\n\t\tcompileContractWithStorageAndParameter\n\t}\n}\n \nexport const compile = async (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst {listContractModules, compileContractWithStorageAndParameter} = inject(commonObj);\n\n\tconst sourceFile = parsedArgs.sourceFile;\n\tif (!isLIGOFile(sourceFile)) {\n\t\tsendErr(`${sourceFile} is not a LIGO file`);\n\t\treturn;\n\t}\n\tif (isStorageListFile(sourceFile) || isParameterListFile(sourceFile)) {\n\t\tsendErr(`Storage and parameter list files are not meant to be compiled directly`);\n\t\treturn;\n\t}\n\tif (isUnsupportedLigoSyntax(sourceFile)) {\n\t\tsendErr(`Unsupported LIGO syntax detected in ${sourceFile}. Note, we only support .jsligo and .mligo files.`);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst modules = await listContractModules(parsedArgs, sourceFile);\n\t\tif (modules.length === 0) {\n\t\t\treturn sendJsonRes([\n\t\t\t\t{\n\t\t\t\t\tsource: sourceFile,\n\t\t\t\t\tartifact: `No contract modules found in \"${sourceFile}\"`,\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\tlet allCompileResults: TableRow[] = [];\n\t\tfor (const module of modules) {\n\t\t\t// If we're only to compile a particular module, then we'll skip any that don't match\n\t\t\tif (parsedArgs.module && parsedArgs.module !== module.moduleName) continue;\n\n\t\t\tconst compileResults = await compileContractWithStorageAndParameter(parsedArgs, sourceFile, module);\n\t\t\tallCompileResults = allCompileResults.concat(compileResults);\n\t\t}\n\n\t\tsendJsonRes(allCompileResults, { footer: `\\nCompiled ${allCompileResults.length} contract(s) in \"${sourceFile}\"` });\n\t} catch (err) {\n\t\tsendErr(`Error processing \"${sourceFile}\": ${err}`);\n\t}\n};\n\nexport default compile;\n","import { sendErr, sendJsonRes } from '@taqueria/node-sdk';\nimport glob from 'fast-glob';\nimport { join } from 'path';\nimport { CompileAllOpts, CompileAllOpts as Opts, CompileOpts, Common } from './common';\nimport {\n\tisParameterListFile,\n\tisStorageListFile,\n\tTableRow,\n\tinject\n} from './compile';\n\nconst compileAll = async (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst {listContractModules, compileContractWithStorageAndParameter} = inject(commonObj);\n\n\tlet compilePromises: Promise<TableRow[]>[] = [];\n\n\tconst contractFilenames = await glob(\n\t\t['**/*.ligo', '**/*.religo', '**/*.mligo', '**/*.jsligo'],\n\t\t{\n\t\t\tcwd: join(parsedArgs.config.projectDir, parsedArgs.config.contractsDir ?? 'contracts'),\n\t\t\tabsolute: false,\n\t\t},\n\t);\n\n\tfor (const filename of contractFilenames) {\n\t\tif (isStorageListFile(filename) || isParameterListFile(filename)) continue;\n\t\tconst moduleNames = await listContractModules(parsedArgs as unknown as CompileAllOpts, filename);\n\t\tfor (const moduleName of moduleNames) {\n\t\t\tcompilePromises.push(compileContractWithStorageAndParameter(parsedArgs as CompileOpts, filename, moduleName));\n\t\t}\n\t}\n\n\treturn Promise.all(compilePromises)\n\t\t.then(tables => tables.flat())\n\t\t.then(sendJsonRes)\n\t\t.catch(err => sendErr(err, false));\n};\n\nexport default compileAll;\n","import { execCmd, getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';\nimport { readJsonFile, writeJsonFile } from '@taqueria/node-sdk';\nimport { join } from 'path';\nimport { configure, LigoOpts as Opts, Common } from './common';\n\n\n\nconst getArbitraryLigoCmd = (\n\tcommonObj: Common,\n\tparsedArgs: Opts,\n\tuid: string,\n\tgid: string,\n\tuserArgs: string,\n): [string, Record<string, string>] => {\n\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\tif (!projectDir) throw `No project directory provided`;\n\n\tconst userMap = uid && gid ? `${uid}:${gid}` : uid;\n\tconst userMapArgs = uid ? ['-u', userMap] : [];\n\n\tconst binary = 'docker';\n\tconst baseArgs = [\n\t\t'run',\n\t\t'--rm',\n\t\t'-v',\n\t\t`${projectDir}:/project`,\n\t\t'-w',\n\t\t'/project',\n\t\t...userMapArgs,\n\t\tcommonObj.getLigoDockerImage(),\n\t];\n\tconst processedUserArgs = userArgs.split(' ').map(arg => arg.startsWith('\\\\-') ? arg.substring(1) : arg).filter(arg =>\n\t\targ\n\t);\n\tconst args = [...baseArgs, ...processedUserArgs, '--skip-analytics'];\n\tconst envVars = { 'DOCKER_DEFAULT_PLATFORM': 'linux/amd64' };\n\treturn [\n\t\t[binary, ...args].join(' '),\n\t\tenvVars,\n\t];\n};\n\nconst ensureEsyExists = async (parsedArgs: Opts): Promise<string> => {\n\tconst esyJsonPath = join(parsedArgs.projectDir, 'esy.json');\n\n\ttry {\n\t\treturn await readJsonFile(esyJsonPath);\n\t} catch {\n\t\treturn await writeJsonFile(esyJsonPath)({});\n\t}\n};\n\nconst runArbitraryLigoCmd = (commonObj: Common, parsedArgs: Opts, cmd: string): Promise<string> =>\n\tensureEsyExists(parsedArgs)\n\t\t.then(getArch)\n\t\t.then(async () => {\n\t\t\tconst uid = await execCmd('id -u');\n\t\t\tconst gid = await execCmd('id -g');\n\t\t\treturn [uid.stdout.trim(), gid.stdout.trim()];\n\t\t})\n\t\t.then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd))\n\t\t.then(([cmd, envVars]) => spawnCmd(cmd, envVars))\n\t\t.then(code =>\n\t\t\tcode !== null && code === 0\n\t\t\t\t? `Command \"${cmd}\" ran successfully by LIGO`\n\t\t\t\t: `Command \"${cmd}\" failed. Please check your command`\n\t\t)\n\t\t.catch(err => sendAsyncErr(`An internal error has occurred: ${err.message}`));\n\nconst ligo = (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst args = parsedArgs.command;\n\treturn runArbitraryLigoCmd(commonObj, parsedArgs, args).then(sendRes).catch(err => sendAsyncErr(err, false));\n};\n\nexport default ligo;\n","import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';\nimport { emitExternalError, getInputFilenameRelPath, TestOpts as Opts, Common } from './common';\n\ntype TableRow = { contract: string; testResults: string };\n\nconst inject = (commonObj: Common) => {\n\tconst {getLigoDockerImage} = commonObj;\n\n\n\tconst getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {\n\t\tconst projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;\n\t\tif (!projectDir) throw `No project directory provided`;\n\t\tconst baseCmd =\n\t\t\t`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \\\"${projectDir}\\\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} run test`;\n\t\tconst inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);\n\t\tconst cmd = `${baseCmd} ${inputFile}`;\n\t\treturn cmd;\n\t};\n\n\tconst testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>\n\t\tgetArch()\n\t\t\t.then(() => getTestContractCmd(parsedArgs, sourceFile))\n\t\t\t.then(execCmd)\n\t\t\t.then(({ stdout, stderr }) => {\n\t\t\t\tif (stderr.length > 0) sendWarn(stderr);\n\t\t\t\tconst result = '🎉 All tests passed 🎉';\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\ttestResults: stdout.length > 0 ? `${stdout}\\n${result}` : result,\n\t\t\t\t};\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\temitExternalError(err, sourceFile);\n\t\t\t\treturn {\n\t\t\t\t\tcontract: sourceFile,\n\t\t\t\t\ttestResults: 'Some tests failed :(',\n\t\t\t\t};\n\t\t\t});\n\t\t\t\n\treturn {\n\t\ttestContract,\n\t\tgetTestContractCmd\n\t}\n}\n\n\n\nconst test = (commonObj: Common, parsedArgs: Opts): Promise<void> => {\n\tconst { testContract } = inject(commonObj);\n\n\tconst sourceFile = parsedArgs.sourceFile;\n\tif (!sourceFile) return sendAsyncErr(`No source file provided`);\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,eAAe,MAAM,gBAAgB;;;ACA9D,SAAS,oBAAoB;AAE7B,SAAS,iBAAiB;;;ACFnB,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcvB,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ADJ/B,IAAM,kBAAkB,OAAO,cAAsB,WAAgD;AACpG,QAAM,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,CAAC;AAAA,MACD,KAAK,OAAO;AAAA,QACX,MAAM;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,QACb,SAAS;AAAA,QACT,QAAQ;AAAA,MACT,CAAC;AAAA,IACF;AAAA,IACA,WAAW;AAAA,MACV,SAAS,OAAO;AAAA,QACf,UAAU;AAAA,QACV,SAAS;AAAA,QACT,aAAa;AAAA,QACb,aAAa;AAAA,UACZ,cAAc,OAAO;AAAA,YACpB,aAAa;AAAA,YACb,MAAM;AAAA,YACN,aAAa;AAAA,UACd,CAAC;AAAA,QACF;AAAA,QACA,SAAS;AAAA,UACR,OAAO,OAAO;AAAA,YACb,WAAW;AAAA,YACX,MAAM;AAAA,YACN,MAAM;AAAA,YACN,aAAa;AAAA,UACd,CAAC;AAAA,QACF;AAAA,QACA,SAAS;AAAA,MACV,CAAC;AAAA,IACF;AAAA,IACA,OAAO,aAAK,SAAS,aAAa,SAAS,iBAAiB;AAAA,IAC5D,aAAa,QAAQ,SAAS;AAAA,EAC/B;AAEA,SAAO,OAAO,OAAO,MAAM,SAAS,eAAe,SAAS,aAAa,MAAM,IAAI,QAAQ,SAAS,YAAY;AACjH;","names":["sendAsyncErr","sendErr","writeFile","join","join","writeFile","sendErr","sendErr","sendJsonRes","join","join","sendJsonRes","sendErr","execCmd","getArch","sendAsyncErr","sendRes","join","cmd","execCmd","getArch","sendAsyncErr","sendJsonRes","sendWarn","inject","getArch","execCmd","sendWarn","sendAsyncErr","sendJsonRes","sendAsyncErr"]}
|
package/index.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';
|
|
2
|
+
import * as PluginSchema from '@taqueria/protocol/PluginSchema';
|
|
3
|
+
|
|
4
|
+
import createContract from './createContract';
|
|
5
|
+
import main from './main';
|
|
6
|
+
|
|
7
|
+
type PluginConfigurator = (plugin: PluginSchema.RawPluginSchema) => PluginSchema.RawPluginSchema;
|
|
8
|
+
type ConfiguratorArgs = {
|
|
9
|
+
name: string;
|
|
10
|
+
alias: string;
|
|
11
|
+
configurator?: PluginConfigurator;
|
|
12
|
+
unparsedArgs: string[];
|
|
13
|
+
dockerImage: string;
|
|
14
|
+
dockerImageEnvVar: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const configurePlugin = (settings: ConfiguratorArgs) => {
|
|
18
|
+
const schema = {
|
|
19
|
+
name: settings.name,
|
|
20
|
+
schema: '1.0',
|
|
21
|
+
version: '0.1',
|
|
22
|
+
alias: settings.alias,
|
|
23
|
+
tasks: [
|
|
24
|
+
Task.create({
|
|
25
|
+
task: 'ligo',
|
|
26
|
+
command: 'ligo',
|
|
27
|
+
description:
|
|
28
|
+
'This task allows you to run arbitrary LIGO native commands. Note that they might not benefit from the abstractions provided by Taqueria',
|
|
29
|
+
options: [
|
|
30
|
+
Option.create({
|
|
31
|
+
shortFlag: 'c',
|
|
32
|
+
flag: 'command',
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'The command to be passed to the underlying LIGO binary, wrapped in quotes',
|
|
35
|
+
required: true,
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
handler: 'proxy',
|
|
39
|
+
encoding: 'none',
|
|
40
|
+
}),
|
|
41
|
+
Task.create({
|
|
42
|
+
task: 'compile',
|
|
43
|
+
command: 'compile <sourceFile>',
|
|
44
|
+
aliases: ['c', 'compile-ligo'],
|
|
45
|
+
description:
|
|
46
|
+
'Compile a smart contract written in a LIGO syntax to Michelson code, along with its associated storage/parameter list files if they are found',
|
|
47
|
+
options: [
|
|
48
|
+
Option.create({
|
|
49
|
+
flag: 'json',
|
|
50
|
+
boolean: true,
|
|
51
|
+
description: 'Emit JSON-encoded Michelson',
|
|
52
|
+
}),
|
|
53
|
+
Option.create({
|
|
54
|
+
flag: 'module',
|
|
55
|
+
shortFlag: 'm',
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'The LIGO module to be compiled',
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
handler: 'proxy',
|
|
61
|
+
encoding: 'json',
|
|
62
|
+
}),
|
|
63
|
+
Task.create({
|
|
64
|
+
task: 'compile-all',
|
|
65
|
+
command: 'compile-all',
|
|
66
|
+
description:
|
|
67
|
+
'Compile all main smart contracts written in a LIGO syntax to Michelson code, along with their associated storage/parameter list files if they are found',
|
|
68
|
+
options: [
|
|
69
|
+
Option.create({
|
|
70
|
+
flag: 'json',
|
|
71
|
+
boolean: true,
|
|
72
|
+
description: 'Emit JSON-encoded Michelson',
|
|
73
|
+
}),
|
|
74
|
+
],
|
|
75
|
+
handler: 'proxy',
|
|
76
|
+
encoding: 'json',
|
|
77
|
+
}),
|
|
78
|
+
Task.create({
|
|
79
|
+
task: 'test',
|
|
80
|
+
command: 'test <sourceFile>',
|
|
81
|
+
description: 'Test a smart contract written in LIGO',
|
|
82
|
+
handler: 'proxy',
|
|
83
|
+
encoding: 'json',
|
|
84
|
+
}),
|
|
85
|
+
Task.create({
|
|
86
|
+
task: 'get-image',
|
|
87
|
+
command: 'get-image',
|
|
88
|
+
description: 'Gets the name of the image to be used',
|
|
89
|
+
handler: 'proxy',
|
|
90
|
+
hidden: true,
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
93
|
+
templates: [
|
|
94
|
+
Template.create({
|
|
95
|
+
template: 'contract',
|
|
96
|
+
command: 'contract <sourceFileName>',
|
|
97
|
+
description: 'Create a LIGO contract with boilerplate code',
|
|
98
|
+
positionals: [
|
|
99
|
+
PositionalArg.create({
|
|
100
|
+
placeholder: 'sourceFileName',
|
|
101
|
+
type: 'string',
|
|
102
|
+
description: 'The name of the LIGO contract to generate',
|
|
103
|
+
}),
|
|
104
|
+
],
|
|
105
|
+
options: [
|
|
106
|
+
Option.create({
|
|
107
|
+
shortFlag: 's',
|
|
108
|
+
flag: 'syntax',
|
|
109
|
+
type: 'string',
|
|
110
|
+
description: 'The syntax used in the contract',
|
|
111
|
+
}),
|
|
112
|
+
],
|
|
113
|
+
handler: createContract,
|
|
114
|
+
}),
|
|
115
|
+
],
|
|
116
|
+
proxy: main(settings.dockerImage, settings.dockerImageEnvVar),
|
|
117
|
+
postInstall: `node ${__dirname}/postinstall.js`,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
return Plugin.create(() => settings.configurator ? settings.configurator(schema) : schema, settings.unparsedArgs);
|
|
121
|
+
};
|
package/ligo.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { execCmd, getArch, sendAsyncErr, sendRes, spawnCmd } from '@taqueria/node-sdk';
|
|
2
|
+
import { readJsonFile, writeJsonFile } from '@taqueria/node-sdk';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { Common, configure, LigoOpts as Opts } from './common';
|
|
5
|
+
|
|
6
|
+
const getArbitraryLigoCmd = (
|
|
7
|
+
commonObj: Common,
|
|
8
|
+
parsedArgs: Opts,
|
|
9
|
+
uid: string,
|
|
10
|
+
gid: string,
|
|
11
|
+
userArgs: string,
|
|
12
|
+
): [string, Record<string, string>] => {
|
|
13
|
+
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
14
|
+
if (!projectDir) throw `No project directory provided`;
|
|
15
|
+
|
|
16
|
+
const userMap = uid && gid ? `${uid}:${gid}` : uid;
|
|
17
|
+
const userMapArgs = uid ? ['-u', userMap] : [];
|
|
18
|
+
|
|
19
|
+
const binary = 'docker';
|
|
20
|
+
const baseArgs = [
|
|
21
|
+
'run',
|
|
22
|
+
'--rm',
|
|
23
|
+
'-v',
|
|
24
|
+
`${projectDir}:/project`,
|
|
25
|
+
'-w',
|
|
26
|
+
'/project',
|
|
27
|
+
...userMapArgs,
|
|
28
|
+
commonObj.getLigoDockerImage(),
|
|
29
|
+
];
|
|
30
|
+
const processedUserArgs = userArgs.split(' ').map(arg => arg.startsWith('\\-') ? arg.substring(1) : arg).filter(arg =>
|
|
31
|
+
arg
|
|
32
|
+
);
|
|
33
|
+
const args = [...baseArgs, ...processedUserArgs, '--skip-analytics'];
|
|
34
|
+
const envVars = { 'DOCKER_DEFAULT_PLATFORM': 'linux/amd64' };
|
|
35
|
+
return [
|
|
36
|
+
[binary, ...args].join(' '),
|
|
37
|
+
envVars,
|
|
38
|
+
];
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const ensureEsyExists = async (parsedArgs: Opts): Promise<string> => {
|
|
42
|
+
const esyJsonPath = join(parsedArgs.projectDir, 'esy.json');
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
return await readJsonFile(esyJsonPath);
|
|
46
|
+
} catch {
|
|
47
|
+
return await writeJsonFile(esyJsonPath)({});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const runArbitraryLigoCmd = (commonObj: Common, parsedArgs: Opts, cmd: string): Promise<string> =>
|
|
52
|
+
ensureEsyExists(parsedArgs)
|
|
53
|
+
.then(getArch)
|
|
54
|
+
.then(async () => {
|
|
55
|
+
const uid = await execCmd('id -u');
|
|
56
|
+
const gid = await execCmd('id -g');
|
|
57
|
+
return [uid.stdout.trim(), gid.stdout.trim()];
|
|
58
|
+
})
|
|
59
|
+
.then(([uid, gid]) => getArbitraryLigoCmd(commonObj, parsedArgs, uid, gid, cmd))
|
|
60
|
+
.then(([cmd, envVars]) => spawnCmd(cmd, envVars))
|
|
61
|
+
.then(code =>
|
|
62
|
+
code !== null && code === 0
|
|
63
|
+
? `Command "${cmd}" ran successfully by LIGO`
|
|
64
|
+
: `Command "${cmd}" failed. Please check your command`
|
|
65
|
+
)
|
|
66
|
+
.catch(err => sendAsyncErr(`An internal error has occurred: ${err.message}`));
|
|
67
|
+
|
|
68
|
+
const ligo = (commonObj: Common, parsedArgs: Opts): Promise<void> => {
|
|
69
|
+
const args = parsedArgs.command;
|
|
70
|
+
return runArbitraryLigoCmd(commonObj, parsedArgs, args).then(sendRes).catch(err => sendAsyncErr(err, false));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default ligo;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const mligo_template = `
|
|
2
|
+
type storage = int
|
|
3
|
+
type return = operation list * storage
|
|
4
|
+
|
|
5
|
+
(* Three entrypoints *)
|
|
6
|
+
[@entry] let increment (delta : int) (store : storage) : return =
|
|
7
|
+
[], store + delta
|
|
8
|
+
[@entry] let decrement (delta : int) (store : storage) : return =
|
|
9
|
+
[], store - delta
|
|
10
|
+
[@entry] let reset (() : unit) (_ : storage) : return =
|
|
11
|
+
[], 0
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const jsligo_template = `
|
|
15
|
+
type storage = int;
|
|
16
|
+
type ret = [list<operation>, storage];
|
|
17
|
+
|
|
18
|
+
// Three entrypoints
|
|
19
|
+
|
|
20
|
+
// @entry
|
|
21
|
+
const increment = (delta : int, store : storage) : ret =>
|
|
22
|
+
[list([]), store + delta];
|
|
23
|
+
|
|
24
|
+
// @entry
|
|
25
|
+
const decrement = (delta : int, store : storage) : ret =>
|
|
26
|
+
[list([]), store - delta];
|
|
27
|
+
|
|
28
|
+
// @entry
|
|
29
|
+
const reset = (_ : unit, _ : storage) : ret =>
|
|
30
|
+
[list([]), 0];
|
|
31
|
+
`;
|
package/main.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
|
|
2
|
+
import { configure, IntersectionOpts as Opts } from './common';
|
|
3
|
+
import compile from './compile';
|
|
4
|
+
import compileAll from './compile-all';
|
|
5
|
+
import ligo from './ligo';
|
|
6
|
+
import test from './test';
|
|
7
|
+
|
|
8
|
+
const main = (dockerImage: string, dockerImageEnvVar: string) => (parsedArgs: RequestArgs.t): Promise<void> => {
|
|
9
|
+
const commonObj = configure(dockerImage, dockerImageEnvVar);
|
|
10
|
+
const unsafeOpts = parsedArgs as unknown as Opts;
|
|
11
|
+
switch (unsafeOpts.task) {
|
|
12
|
+
case 'ligo':
|
|
13
|
+
return ligo(commonObj, unsafeOpts);
|
|
14
|
+
case 'compile':
|
|
15
|
+
return compile(commonObj, unsafeOpts);
|
|
16
|
+
case 'compile-all':
|
|
17
|
+
return compileAll(commonObj, unsafeOpts);
|
|
18
|
+
case 'test':
|
|
19
|
+
return test(commonObj, parsedArgs);
|
|
20
|
+
case 'get-image':
|
|
21
|
+
return sendAsyncRes(commonObj.getLigoDockerImage());
|
|
22
|
+
default:
|
|
23
|
+
return sendAsyncErr(`${unsafeOpts.task} is not an understood task by the LIGO plugin`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default main;
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taqueria/lib-ligo",
|
|
3
|
+
"version": "0.40.10",
|
|
4
|
+
"description": "A taqueria library which provides common functionality for the LIGO and LIGO Legacy Plugins",
|
|
5
|
+
"targets": {
|
|
6
|
+
"default": {
|
|
7
|
+
"source": "./index.ts",
|
|
8
|
+
"distDir": "./",
|
|
9
|
+
"context": "node",
|
|
10
|
+
"isLibrary": true
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
15
|
+
"build": "npx tsc -noEmit -p ./tsconfig.json && npx tsup",
|
|
16
|
+
"pluginInfo": "npx ts-node index.ts --taqRun pluginInfo --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\",\"artifactsDir\": \"artifacts\"}' --projectDir ../test-project --configDir ./.taq",
|
|
17
|
+
"compile": "npx ts-node index.ts --taqRun proxy --task compile --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\",\"artifactsDir\": \"artifacts\"}' --projectDir ../test-project --configDir ./.taq",
|
|
18
|
+
"debugPluginInfo": "npx ts-node --inspect index.ts --taqRun pluginInfo --i18n '{\"foo\":\"bar\"}' --config '{\"contractsDir\":\"contracts\",\"testsDir\": \"tests\"}' --projectDir ../test-project --configDir ./.taq"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"taqueria",
|
|
22
|
+
"tezos",
|
|
23
|
+
"build",
|
|
24
|
+
"pinnaclelabs",
|
|
25
|
+
"pinnacle-labs",
|
|
26
|
+
"plugin",
|
|
27
|
+
"ligo",
|
|
28
|
+
"ligolang",
|
|
29
|
+
"smart contract",
|
|
30
|
+
"compile"
|
|
31
|
+
],
|
|
32
|
+
"author": "Pinnacle Labs",
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/pinnacle-labs/taqueria.git",
|
|
37
|
+
"directory": "taqueria-plugin-ligo"
|
|
38
|
+
},
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/pinnacle-labs/taqueria/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/pinnacle-labs/taqueria#readme",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@taqueria/node-sdk": "^0.40.10",
|
|
45
|
+
"fast-glob": "^3.3.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"tsup": "^7.2.0",
|
|
49
|
+
"typescript": "^5.2.2"
|
|
50
|
+
},
|
|
51
|
+
"tsup": {
|
|
52
|
+
"entry": [
|
|
53
|
+
"index.ts"
|
|
54
|
+
],
|
|
55
|
+
"sourcemap": true,
|
|
56
|
+
"target": "node16",
|
|
57
|
+
"outDir": "./",
|
|
58
|
+
"dts": true,
|
|
59
|
+
"clean": false,
|
|
60
|
+
"skipNodeModulesBundle": true,
|
|
61
|
+
"platform": "node",
|
|
62
|
+
"format": [
|
|
63
|
+
"esm",
|
|
64
|
+
"cjs"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"gitHead": "ff58a2fc06ad233869ad6be574093c8b3b272e2e"
|
|
68
|
+
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
console.log('LIGO collects anonymous usage data by default. If you prefer not to participate, you may opt out by executing the command: `taq ligo -c "analytics deny"`. For more information, please contact the LIGO team on the Tezos Discord server: https://discord.gg/tezos');
|
|
5
|
+
|
|
6
|
+
const directoryPath = path.join(process.cwd(), '.ligo');
|
|
7
|
+
const filePath = path.join(directoryPath, 'term_acceptance');
|
|
8
|
+
|
|
9
|
+
// Check if the .ligo directory exists
|
|
10
|
+
if (!fs.existsSync(directoryPath)) {
|
|
11
|
+
// If not, create it
|
|
12
|
+
fs.mkdirSync(directoryPath);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Check if the term-acceptance file exists within .ligo
|
|
16
|
+
if (!fs.existsSync(filePath)) {
|
|
17
|
+
// If not, create and write 'accepted' to it
|
|
18
|
+
fs.writeFileSync(filePath, 'accepted');
|
|
19
|
+
}
|
package/test.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { execCmd, getArch, sendAsyncErr, sendJsonRes, sendWarn } from '@taqueria/node-sdk';
|
|
2
|
+
import { Common, emitExternalError, getInputFilenameRelPath, TestOpts as Opts } from './common';
|
|
3
|
+
|
|
4
|
+
type TableRow = { contract: string; testResults: string };
|
|
5
|
+
|
|
6
|
+
const inject = (commonObj: Common) => {
|
|
7
|
+
const { getLigoDockerImage } = commonObj;
|
|
8
|
+
|
|
9
|
+
const getTestContractCmd = (parsedArgs: Opts, sourceFile: string): string => {
|
|
10
|
+
const projectDir = process.env.PROJECT_DIR ?? parsedArgs.projectDir;
|
|
11
|
+
if (!projectDir) throw `No project directory provided`;
|
|
12
|
+
const baseCmd =
|
|
13
|
+
`DOCKER_DEFAULT_PLATFORM=linux/amd64 docker run --rm -v \"${projectDir}\":/project -w /project -u $(id -u):$(id -g) ${getLigoDockerImage()} run test`;
|
|
14
|
+
const inputFile = getInputFilenameRelPath(parsedArgs, sourceFile);
|
|
15
|
+
const cmd = `${baseCmd} ${inputFile}`;
|
|
16
|
+
return cmd;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const testContract = (parsedArgs: Opts, sourceFile: string): Promise<TableRow> =>
|
|
20
|
+
getArch()
|
|
21
|
+
.then(() => getTestContractCmd(parsedArgs, sourceFile))
|
|
22
|
+
.then(execCmd)
|
|
23
|
+
.then(({ stdout, stderr }) => {
|
|
24
|
+
if (stderr.length > 0) sendWarn(stderr);
|
|
25
|
+
const result = '🎉 All tests passed 🎉';
|
|
26
|
+
return {
|
|
27
|
+
contract: sourceFile,
|
|
28
|
+
testResults: stdout.length > 0 ? `${stdout}\n${result}` : result,
|
|
29
|
+
};
|
|
30
|
+
})
|
|
31
|
+
.catch(err => {
|
|
32
|
+
emitExternalError(err, sourceFile);
|
|
33
|
+
return {
|
|
34
|
+
contract: sourceFile,
|
|
35
|
+
testResults: 'Some tests failed :(',
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
testContract,
|
|
41
|
+
getTestContractCmd,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const test = (commonObj: Common, parsedArgs: Opts): Promise<void> => {
|
|
46
|
+
const { testContract } = inject(commonObj);
|
|
47
|
+
|
|
48
|
+
const sourceFile = parsedArgs.sourceFile;
|
|
49
|
+
if (!sourceFile) return sendAsyncErr(`No source file provided`);
|
|
50
|
+
return testContract(parsedArgs, sourceFile).then(result => [result]).then(sendJsonRes).catch(err =>
|
|
51
|
+
sendAsyncErr(err, false)
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default test;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "ES2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
+
"lib": [
|
|
16
|
+
"ES2021.String"
|
|
17
|
+
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
18
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
19
|
+
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
20
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
21
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
|
|
22
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
23
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
|
|
24
|
+
// "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
|
|
25
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
26
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
27
|
+
|
|
28
|
+
/* Modules */
|
|
29
|
+
"module": "CommonJS", /* Specify what module code is generated. */
|
|
30
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
31
|
+
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
32
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
33
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
34
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
35
|
+
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
|
|
36
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
37
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
38
|
+
// "resolveJsonModule": true, /* Enable importing .json files */
|
|
39
|
+
// "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
|
|
40
|
+
|
|
41
|
+
/* JavaScript Support */
|
|
42
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
|
|
43
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
44
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
|
|
45
|
+
|
|
46
|
+
/* Emit */
|
|
47
|
+
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
48
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
49
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
50
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
51
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
|
|
52
|
+
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
53
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
54
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
55
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
56
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
|
|
57
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
58
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
59
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
60
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
61
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
62
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
63
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
64
|
+
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
|
|
65
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
|
|
66
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
67
|
+
// "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
|
|
68
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
69
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
70
|
+
|
|
71
|
+
/* Interop Constraints */
|
|
72
|
+
"isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
73
|
+
"allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
74
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
|
|
75
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
76
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
77
|
+
|
|
78
|
+
/* Type Checking */
|
|
79
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
80
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
|
|
81
|
+
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
|
|
82
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
83
|
+
// "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
|
|
84
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
85
|
+
// "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
|
|
86
|
+
// "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
|
|
87
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
88
|
+
// "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
|
|
89
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
|
|
90
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
91
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
92
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
93
|
+
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
|
94
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
95
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
|
|
96
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
97
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
98
|
+
|
|
99
|
+
/* Completeness */
|
|
100
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
101
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
102
|
+
}
|
|
103
|
+
}
|