@taqueria/plugin-jest 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.cjs CHANGED
@@ -159,28 +159,30 @@ var contractTestTemplate_default = (args) => {
159
159
 
160
160
  // proxy.ts
161
161
  var import_node_sdk3 = require("@taqueria/node-sdk");
162
- var import_execa = require("execa");
162
+ var import_child_process = require("child_process");
163
163
  var execCmd = (cmd, args, env) => {
164
- var _a, _b;
165
- const child = (0, import_execa.execa)(cmd, args, {
166
- shell: true,
167
- reject: false,
168
- env: { FORCE_COLOR: "true", TAQUERIA_ENV: env }
164
+ return new Promise((resolve) => {
165
+ const child = (0, import_child_process.spawn)(cmd, args, {
166
+ shell: true,
167
+ env: { ...process.env, FORCE_COLOR: "true", TAQUERIA_ENV: env }
168
+ });
169
+ child.stdout.pipe(process.stdout);
170
+ child.stderr.pipe(process.stderr);
171
+ child.on("close", (code) => {
172
+ resolve(code ?? 0);
173
+ });
169
174
  });
170
- (_a = child.stdout) == null ? void 0 : _a.pipe(process.stdout);
171
- (_b = child.stderr) == null ? void 0 : _b.pipe(process.stderr);
172
- return child;
173
175
  };
174
176
  var proxy_default = (args) => {
175
177
  const parsedArgs = toRequestArgs(args);
176
178
  return ensureSelectedPartitionExists(parsedArgs, parsedArgs.init ? true : false).then((configAbsPath) => {
177
179
  if (!parsedArgs.init) {
178
- const retval = parsedArgs.testPattern ? execCmd("npx", ["jest", "-c", configAbsPath, "--testPathPattern", parsedArgs.testPattern], parsedArgs.env) : execCmd("npx", ["jest", "-c", configAbsPath], parsedArgs.env);
179
- return retval.then((child) => {
180
- if (child.exitCode === 0)
181
- return;
182
- else
183
- process.exit(child.exitCode);
180
+ const jestArgs = ["-c", configAbsPath];
181
+ if (parsedArgs.testPattern) {
182
+ jestArgs.push("--testPathPattern", parsedArgs.testPattern);
183
+ }
184
+ return execCmd("npx", ["jest", ...jestArgs], parsedArgs.env).then((exitCode) => {
185
+ if (exitCode !== 0) process.exit(exitCode);
184
186
  });
185
187
  }
186
188
  return (0, import_node_sdk3.sendAsyncRes)("Initialized successfully.");
package/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts","common.ts","contractTestTemplate.ts","proxy.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport { CustomRequestArgs, toRequestArgs } from './common';\nimport createContractTest from './contractTestTemplate';\nimport proxy from './proxy';\n\nPlugin.create<CustomRequestArgs>(requestArgs => ({\n\tschema: '0.1',\n\tversion: '0.4.0',\n\talias: 'jest',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test [partition]',\n\t\t\tdescription: 'Setup a directory as a partition to run Jest tests',\n\t\t\taliases: ['jest'],\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'partition',\n\t\t\t\t\tdescription: 'Name of the partition for these tests',\n\t\t\t\t\tdefaultValue: 'tests',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'init',\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tdescription: 'Initializes the partition for Jest',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'testPattern',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdescription: 'Run test files that match the provided pattern',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t],\n\ttemplates: [\n\t\tTemplate.create({\n\t\t\ttemplate: 'contract-test',\n\t\t\tcommand: 'contract-test <michelsonArtifact>',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'michelsonArtifact',\n\t\t\t\t\tdescription: 'Name of the michelson contract (artifact) to generate tests for',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'partition',\n\t\t\t\t\tdescription: 'Partition to place generated test suite',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefaultValue: toRequestArgs(requestArgs).config.jest.testsRootDir,\n\t\t\t\t}),\n\t\t\t],\n\t\t\tdescription: 'Generate integration test for a contract',\n\t\t\thandler: createContractTest,\n\t\t}),\n\t],\n\tproxy,\n\tpostInstall: \"bash -c 'npm install --save-dev ts-jest @types/jest'\",\n}), process.argv);\n","import { noop, RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';\nimport { mkdir, stat, writeFile } from 'fs/promises';\nimport { defaults } from 'jest-config';\nimport { join, relative } from 'path';\nimport JestConfig from './config';\n\nexport type DefaultConfig = typeof defaults;\n\nexport interface CustomRequestArgs extends RequestArgs.t {\n\tconfig: JestConfig;\n\tpartition?: string;\n\tinit?: string;\n\ttestPattern?: string;\n}\n\nexport const toRequestArgs = (args: RequestArgs.t): CustomRequestArgs => {\n\tconst config = {\n\t\t...args.config,\n\t\tjest: {\n\t\t\ttestsRootDir: 'tests',\n\t\t},\n\t};\n\n\treturn {\n\t\t...args,\n\t\tconfig,\n\t};\n};\n\nexport const getDefaultConfig = (defaultConfig: DefaultConfig) => {\n\tconst settings = { ...defaults, preset: 'ts-jest', testEnvironment: 'node' };\n\treturn (\n\t\t`\nmodule.exports = ${JSON.stringify(settings, null, 4)}\n`\n\t);\n};\n\nexport const ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {\n\tconst jestRootConfig = getRootConfigAbspath(projectDir);\n\treturn stat(jestRootConfig)\n\t\t.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))\n\t\t.then(_ => jestRootConfig);\n};\n\nexport const getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>\n\tSanitizedAbsPath.create(\n\t\tjoin(projectDir, '.taq', 'jest.config.js'),\n\t);\n\nexport const getTestsRootDir = (config: JestConfig) => {\n\treturn config.jest.testsRootDir;\n};\n\nexport const toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `\nconst parentConfig = require('${rootConfigRelPath}')\n\nmodule.exports = {\n ...parentConfig,\n roots: [\n \"${partitionRelpath}\"\n ]\n}\n`;\n\nexport const getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);\n\nexport const getPartitionConfigAbspath = (partitionDir: string) =>\n\tSanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));\n\nexport const initPartition = (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) => {\n\treturn writeFile(\n\t\tgetPartitionConfigAbspath(partitionDir),\n\t\ttoPartitionCfg(\n\t\t\tSanitizedPath.create('./'),\n\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t),\n\t);\n};\n\nexport const ensurePartitionExists = async (\n\tpartitionDir: SanitizedAbsPath.t,\n\tprojectDir: SanitizedAbsPath.t,\n\tforceCreate = false,\n) =>\n\tensureRootConfigExists(projectDir)\n\t\t.then(_ => stat(partitionDir))\n\t\t.then(stats =>\n\t\t\tstats.isFile()\n\t\t\t\t? sendAsyncErr(`${partitionDir} is an invalid partition directory`)\n\t\t\t\t: stats\n\t\t)\n\t\t.catch(_ => mkdir(partitionDir, { recursive: true }))\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir))\n\t\t.then(partitionCfgAbsPath =>\n\t\t\tstat(partitionCfgAbsPath)\n\t\t\t\t.then(_ => forceCreate ? initPartition(partitionDir, projectDir) : undefined)\n\t\t\t\t.catch(_ => initPartition(partitionDir, projectDir))\n\t\t)\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir));\n\nexport const ensureSelectedPartitionExists = (args: CustomRequestArgs, forceCreate = false) =>\n\targs.partition\n\t\t? ensurePartitionExists(\n\t\t\tSanitizedAbsPath.create(join(args.projectDir, args.partition)),\n\t\t\tSanitizedPath.create(args.projectDir),\n\t\t\tforceCreate,\n\t\t)\n\t\t: ensurePartitionExists(\n\t\t\tSanitizedAbsPath.create(\n\t\t\t\tjoin(args.projectDir, getTestsRootDir(args.config)),\n\t\t\t),\n\t\t\tSanitizedPath.create(args.projectDir),\n\t\t\tforceCreate,\n\t\t);\n","// import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';\nimport { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { generateContractTypesProcessContractFiles } from '@taqueria/plugin-contract-types/src/cli-process.js';\nimport {\n\tcreateTestingCodeGenerator,\n\tnormalizeContractName,\n} from '@taqueria/plugin-contract-types/src/generator/testing-code-generator.js';\nimport { readFile, stat, writeFile } from 'fs/promises';\nimport { basename, dirname, join } from 'path';\nimport { CustomRequestArgs, ensureSelectedPartitionExists, getPartitionAbspath, getTestsRootDir } from './common';\n\ntype Generator = ReturnType<typeof createTestingCodeGenerator>;\n\ninterface Opts extends CustomRequestArgs {\n\treadonly michelsonArtifact?: string;\n\treadonly partition?: string;\n\treadonly name?: string;\n}\n\nconst getMichelsonAbspath = (parsedArgs: Opts) =>\n\tjoin(parsedArgs.config.artifactsDir ?? 'artifacts', parsedArgs.michelsonArtifact!);\n\nconst ensureMichelsonExists = (parsedArgs: Opts) => {\n\tconst abspath = getMichelsonAbspath(parsedArgs);\n\treturn stat(abspath)\n\t\t.then(() => parsedArgs)\n\t\t.catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run \"taq compile\"?`));\n};\n\nconst getPartition = (parsedArgs: Opts) => {\n\tconst partition = parsedArgs.partition ?? getTestsRootDir(parsedArgs.config);\n\treturn getPartitionAbspath(partition);\n};\n\nconst getTypesOutputAbspath = (parsedArgs: Opts) => join(getPartition(parsedArgs), 'types');\n\nconst generateContractTypes = (parsedArgs: Opts) =>\n\tgenerateContractTypesProcessContractFiles({\n\t\tinputTzContractDirectory: parsedArgs.config.artifactsDir ?? 'artifacts',\n\t\tinputFiles: [getMichelsonAbspath(parsedArgs)],\n\t\toutputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),\n\t\tformat: 'tz',\n\t\ttypeAliasMode: 'file',\n\t}).then(_ => parsedArgs);\n\nconst getContractName = (parsedArgs: Opts) =>\n\tparsedArgs.name\n\t\t? parsedArgs.name.trim().replace(/\\.ts$/, '')\n\t\t: basename(parsedArgs.michelsonArtifact!, '.tz');\n\nconst generateTestSuite = (parsedArgs: Opts) => {\n\tconst michelsonAbspath = getMichelsonAbspath(parsedArgs);\n\tconst contractName = getContractName(parsedArgs);\n\tconst partition = getPartition(parsedArgs);\n\tconst jestSuiteAbspath = join(partition, `${contractName}.spec.ts`);\n\n\treturn readFile(michelsonAbspath, { encoding: 'utf-8' })\n\t\t.then(contractSource => ({ contractSource, contractFormat: 'tz' as const }))\n\t\t.then(createTestingCodeGenerator)\n\t\t.then(toJest(contractName))\n\t\t.then(contents => writeFile(jestSuiteAbspath, contents, { encoding: 'utf-8' }))\n\t\t.then(() => jestSuiteAbspath);\n};\n\nconst toJest = (contractName: string) => (generator: Generator) => {\n\tconst methodCalls = generator.methods.map(m => ({\n\t\tname: m.name,\n\t\tmethodCall: generator.generateMethodCall({\n\t\t\tmethodName: m.name,\n\t\t\tformatting: {\n\t\t\t\tindent: 2,\n\t\t\t},\n\t\t}),\n\t\tstorageAccess: generator.generateStorageAccess({ storagePath: '' }),\n\t}));\n\treturn `\nimport { TezosToolkit } from '@taquito/taquito';\nimport { stringToBytes } from '@taquito/utils';\nimport { tas } from './types/type-aliases';\nimport { InMemorySigner } from '@taquito/signer';\nimport { ${normalizeContractName(contractName)}ContractType as ContractType } from './types/${contractName}.types';\nimport { ${normalizeContractName(contractName)}Code as ContractCode } from './types/${contractName}.code';\n\njest.setTimeout(20000)\n\ndescribe('${contractName}', () => {\n\tconst currentEnv = process.env.TAQUERIA_ENV || 'development';\n\tconst envConfig = require('../.taq/config.local.' + currentEnv + '.json')\n const Tezos = new TezosToolkit(envConfig.rpcUrl);\n\tconst key = envConfig.accounts.bob.secretKey.replace('unencrypted:', '')\n\tTezos.setProvider({\n\t\tsigner: new InMemorySigner(key),\n\t });\n let contract: ContractType = undefined as unknown as ContractType;\n beforeAll(async () => {\n ${generator.generateOrigination({ formatting: { indent: 3 } }).code}\n });\n\n${\n\t\tmethodCalls.map(x => `\n it('should call ${x.name}', async () => {\n ${x.storageAccess.getStorageValueFunctionCode}\n const storageValueBefore = await ${x.storageAccess.getStorageValueFunctionName}();\n ${x.methodCall.code}\n const storageValueAfter = await ${x.storageAccess.getStorageValueFunctionName}();\n\n expect(storageValueAfter.toString()).toBe('');\n });\n`).join('')\n\t}});\n`;\n};\n\nexport default (args: RequestArgs.t) => {\n\tconst parsedArgs = args as Opts;\n\tparsedArgs.michelsonArtifact\n\t\t? ensureMichelsonExists(parsedArgs)\n\t\t\t.then(ensureSelectedPartitionExists)\n\t\t\t.then(() => parsedArgs)\n\t\t\t.then(generateContractTypes)\n\t\t\t.then(generateTestSuite)\n\t\t\t.then((outFile: string) => sendAsyncRes(`Test suite generated: ${outFile}`))\n\t\t\t.catch(sendAsyncErr)\n\t\t: sendAsyncErr(`No michelson artifact provided`);\n};\n","import { sendAsyncRes, sendErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk';\nimport { execa } from 'execa';\nimport { CustomRequestArgs, ensureSelectedPartitionExists, toRequestArgs } from './common';\n\nconst execCmd = (cmd: string, args: string[], env: string) => {\n\tconst child = execa(cmd, args, {\n\t\tshell: true,\n\t\treject: false,\n\t\tenv: { FORCE_COLOR: 'true', TAQUERIA_ENV: env },\n\t});\n\n\tchild.stdout?.pipe(process.stdout);\n\tchild.stderr?.pipe(process.stderr);\n\n\treturn child;\n};\nexport default (args: RequestArgs.t) => {\n\tconst parsedArgs = toRequestArgs(args);\n\treturn ensureSelectedPartitionExists(parsedArgs, parsedArgs.init ? true : false)\n\t\t.then(configAbsPath => {\n\t\t\tif (!parsedArgs.init) {\n\t\t\t\tconst retval = parsedArgs.testPattern\n\t\t\t\t\t? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', parsedArgs.testPattern], parsedArgs.env)\n\t\t\t\t\t: execCmd('npx', ['jest', '-c', configAbsPath], parsedArgs.env);\n\t\t\t\treturn retval.then(child => {\n\t\t\t\t\tif (child.exitCode === 0) return;\n\t\t\t\t\telse process.exit(child.exitCode);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn sendAsyncRes('Initialized successfully.');\n\t\t});\n};\n"],"mappings":";;;AAAA,IAAAA,mBAA8D;;;ACA9D,sBAA8D;AAC9D,mBAAgD;AAChD,sBAAuC;AACvC,yBAAyB;AACzB,kBAA+B;AAYxB,IAAM,gBAAgB,CAAC,SAA2C;AACxE,QAAM,SAAS;AAAA,IACd,GAAG,KAAK;AAAA,IACR,MAAM;AAAA,MACL,cAAc;AAAA,IACf;AAAA,EACD;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH;AAAA,EACD;AACD;AAEO,IAAM,mBAAmB,CAAC,kBAAiC;AACjE,QAAM,WAAW,EAAE,GAAG,6BAAU,QAAQ,WAAW,iBAAiB,OAAO;AAC3E,SACC;AAAA,mBACiB,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAAA;AAGpD;AAEO,IAAM,yBAAyB,CAAC,eAAmC;AACzE,QAAM,iBAAiB,qBAAqB,UAAU;AACtD,aAAO,sBAAK,cAAc,EACxB,MAAM,WAAK,2BAAU,gBAAgB,iBAAiB,2BAAQ,CAAC,CAAC,EAChE,KAAK,OAAK,cAAc;AAC3B;AAEO,IAAM,uBAAuB,CAAC,eACpC,8BAAiB;AAAA,MAChB,kBAAK,YAAY,QAAQ,gBAAgB;AAC1C;AAEM,IAAM,kBAAkB,CAAC,WAAuB;AACtD,SAAO,OAAO,KAAK;AACpB;AAEO,IAAM,iBAAiB,CAAC,kBAA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P,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aAAa;AAAA,UACb,SAAS;AAAA,QACV,CAAC;AAAA,QACD,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,EACF;AAAA,EACA,WAAW;AAAA,IACV,0BAAS,OAAO;AAAA,MACf,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,+BAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,UAAU;AAAA,UACV,MAAM;AAAA,QACP,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aAAa;AAAA,UACb,MAAM;AAAA,UACN,cAAc,cAAc,WAAW,EAAE,OAAO,KAAK;AAAA,QACtD,CAAC;AAAA,MACF;AAAA,MACA,aAAa;AAAA,MACb,SAAS;AAAA,IACV,CAAC;AAAA,EACF;AAAA,EACA;AAAA,EACA,aAAa;AACd,IAAI,QAAQ,IAAI;","names":["import_node_sdk","import_node_sdk","import_promises","import_path","import_node_sdk"]}
1
+ {"version":3,"sources":["index.ts","common.ts","contractTestTemplate.ts","proxy.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport { CustomRequestArgs, toRequestArgs } from './common';\nimport createContractTest from './contractTestTemplate';\nimport proxy from './proxy';\n\nPlugin.create<CustomRequestArgs>(requestArgs => ({\n\tschema: '0.1',\n\tversion: '0.4.0',\n\talias: 'jest',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test [partition]',\n\t\t\tdescription: 'Setup a directory as a partition to run Jest tests',\n\t\t\taliases: ['jest'],\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'partition',\n\t\t\t\t\tdescription: 'Name of the partition for these tests',\n\t\t\t\t\tdefaultValue: 'tests',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'init',\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tdescription: 'Initializes the partition for Jest',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'testPattern',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdescription: 'Run test files that match the provided pattern',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t],\n\ttemplates: [\n\t\tTemplate.create({\n\t\t\ttemplate: 'contract-test',\n\t\t\tcommand: 'contract-test <michelsonArtifact>',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'michelsonArtifact',\n\t\t\t\t\tdescription: 'Name of the michelson contract (artifact) to generate tests for',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'partition',\n\t\t\t\t\tdescription: 'Partition to place generated test suite',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefaultValue: toRequestArgs(requestArgs).config.jest.testsRootDir,\n\t\t\t\t}),\n\t\t\t],\n\t\t\tdescription: 'Generate integration test for a contract',\n\t\t\thandler: createContractTest,\n\t\t}),\n\t],\n\tproxy,\n\tpostInstall: \"bash -c 'npm install --save-dev ts-jest @types/jest'\",\n}), process.argv);\n","import { noop, RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';\nimport { mkdir, stat, writeFile } from 'fs/promises';\nimport { defaults } from 'jest-config';\nimport { join, relative } from 'path';\nimport JestConfig from './config';\n\nexport type DefaultConfig = typeof defaults;\n\nexport interface CustomRequestArgs extends RequestArgs.t {\n\tconfig: JestConfig;\n\tpartition?: string;\n\tinit?: string;\n\ttestPattern?: string;\n}\n\nexport const toRequestArgs = (args: RequestArgs.t): CustomRequestArgs => {\n\tconst config = {\n\t\t...args.config,\n\t\tjest: {\n\t\t\ttestsRootDir: 'tests',\n\t\t},\n\t};\n\n\treturn {\n\t\t...args,\n\t\tconfig,\n\t};\n};\n\nexport const getDefaultConfig = (defaultConfig: DefaultConfig) => {\n\tconst settings = { ...defaults, preset: 'ts-jest', testEnvironment: 'node' };\n\treturn (\n\t\t`\nmodule.exports = ${JSON.stringify(settings, null, 4)}\n`\n\t);\n};\n\nexport const ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {\n\tconst jestRootConfig = getRootConfigAbspath(projectDir);\n\treturn stat(jestRootConfig)\n\t\t.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))\n\t\t.then(_ => jestRootConfig);\n};\n\nexport const getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>\n\tSanitizedAbsPath.create(\n\t\tjoin(projectDir, '.taq', 'jest.config.js'),\n\t);\n\nexport const getTestsRootDir = (config: JestConfig) => {\n\treturn config.jest.testsRootDir;\n};\n\nexport const toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `\nconst parentConfig = require('${rootConfigRelPath}')\n\nmodule.exports = {\n ...parentConfig,\n roots: [\n \"${partitionRelpath}\"\n ]\n}\n`;\n\nexport const getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);\n\nexport const getPartitionConfigAbspath = (partitionDir: string) =>\n\tSanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));\n\nexport const initPartition = (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) => {\n\treturn writeFile(\n\t\tgetPartitionConfigAbspath(partitionDir),\n\t\ttoPartitionCfg(\n\t\t\tSanitizedPath.create('./'),\n\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t),\n\t);\n};\n\nexport const ensurePartitionExists = async (\n\tpartitionDir: SanitizedAbsPath.t,\n\tprojectDir: SanitizedAbsPath.t,\n\tforceCreate = false,\n) =>\n\tensureRootConfigExists(projectDir)\n\t\t.then(_ => stat(partitionDir))\n\t\t.then(stats =>\n\t\t\tstats.isFile()\n\t\t\t\t? sendAsyncErr(`${partitionDir} is an invalid partition directory`)\n\t\t\t\t: stats\n\t\t)\n\t\t.catch(_ => mkdir(partitionDir, { recursive: true }))\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir))\n\t\t.then(partitionCfgAbsPath =>\n\t\t\tstat(partitionCfgAbsPath)\n\t\t\t\t.then(_ => forceCreate ? initPartition(partitionDir, projectDir) : undefined)\n\t\t\t\t.catch(_ => initPartition(partitionDir, projectDir))\n\t\t)\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir));\n\nexport const ensureSelectedPartitionExists = (args: CustomRequestArgs, forceCreate = false) =>\n\targs.partition\n\t\t? ensurePartitionExists(\n\t\t\tSanitizedAbsPath.create(join(args.projectDir, args.partition)),\n\t\t\tSanitizedPath.create(args.projectDir),\n\t\t\tforceCreate,\n\t\t)\n\t\t: ensurePartitionExists(\n\t\t\tSanitizedAbsPath.create(\n\t\t\t\tjoin(args.projectDir, getTestsRootDir(args.config)),\n\t\t\t),\n\t\t\tSanitizedPath.create(args.projectDir),\n\t\t\tforceCreate,\n\t\t);\n","// import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';\nimport { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { generateContractTypesProcessContractFiles } from '@taqueria/plugin-contract-types/src/cli-process.js';\nimport {\n\tcreateTestingCodeGenerator,\n\tnormalizeContractName,\n} from '@taqueria/plugin-contract-types/src/generator/testing-code-generator.js';\nimport { readFile, stat, writeFile } from 'fs/promises';\nimport { basename, dirname, join } from 'path';\nimport { CustomRequestArgs, ensureSelectedPartitionExists, getPartitionAbspath, getTestsRootDir } from './common';\n\ntype Generator = ReturnType<typeof createTestingCodeGenerator>;\n\ninterface Opts extends CustomRequestArgs {\n\treadonly michelsonArtifact?: string;\n\treadonly partition?: string;\n\treadonly name?: string;\n}\n\nconst getMichelsonAbspath = (parsedArgs: Opts) =>\n\tjoin(parsedArgs.config.artifactsDir ?? 'artifacts', parsedArgs.michelsonArtifact!);\n\nconst ensureMichelsonExists = (parsedArgs: Opts) => {\n\tconst abspath = getMichelsonAbspath(parsedArgs);\n\treturn stat(abspath)\n\t\t.then(() => parsedArgs)\n\t\t.catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run \"taq compile\"?`));\n};\n\nconst getPartition = (parsedArgs: Opts) => {\n\tconst partition = parsedArgs.partition ?? getTestsRootDir(parsedArgs.config);\n\treturn getPartitionAbspath(partition);\n};\n\nconst getTypesOutputAbspath = (parsedArgs: Opts) => join(getPartition(parsedArgs), 'types');\n\nconst generateContractTypes = (parsedArgs: Opts) =>\n\tgenerateContractTypesProcessContractFiles({\n\t\tinputTzContractDirectory: parsedArgs.config.artifactsDir ?? 'artifacts',\n\t\tinputFiles: [getMichelsonAbspath(parsedArgs)],\n\t\toutputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),\n\t\tformat: 'tz',\n\t\ttypeAliasMode: 'file',\n\t}).then(_ => parsedArgs);\n\nconst getContractName = (parsedArgs: Opts) =>\n\tparsedArgs.name\n\t\t? parsedArgs.name.trim().replace(/\\.ts$/, '')\n\t\t: basename(parsedArgs.michelsonArtifact!, '.tz');\n\nconst generateTestSuite = (parsedArgs: Opts) => {\n\tconst michelsonAbspath = getMichelsonAbspath(parsedArgs);\n\tconst contractName = getContractName(parsedArgs);\n\tconst partition = getPartition(parsedArgs);\n\tconst jestSuiteAbspath = join(partition, `${contractName}.spec.ts`);\n\n\treturn readFile(michelsonAbspath, { encoding: 'utf-8' })\n\t\t.then(contractSource => ({ contractSource, contractFormat: 'tz' as const }))\n\t\t.then(createTestingCodeGenerator)\n\t\t.then(toJest(contractName))\n\t\t.then(contents => writeFile(jestSuiteAbspath, contents, { encoding: 'utf-8' }))\n\t\t.then(() => jestSuiteAbspath);\n};\n\nconst toJest = (contractName: string) => (generator: Generator) => {\n\tconst methodCalls = generator.methods.map(m => ({\n\t\tname: m.name,\n\t\tmethodCall: generator.generateMethodCall({\n\t\t\tmethodName: m.name,\n\t\t\tformatting: {\n\t\t\t\tindent: 2,\n\t\t\t},\n\t\t}),\n\t\tstorageAccess: generator.generateStorageAccess({ storagePath: '' }),\n\t}));\n\treturn `\nimport { TezosToolkit } from '@taquito/taquito';\nimport { stringToBytes } from '@taquito/utils';\nimport { tas } from './types/type-aliases';\nimport { InMemorySigner } from '@taquito/signer';\nimport { ${normalizeContractName(contractName)}ContractType as ContractType } from './types/${contractName}.types';\nimport { ${normalizeContractName(contractName)}Code as ContractCode } from './types/${contractName}.code';\n\njest.setTimeout(20000)\n\ndescribe('${contractName}', () => {\n\tconst currentEnv = process.env.TAQUERIA_ENV || 'development';\n\tconst envConfig = require('../.taq/config.local.' + currentEnv + '.json')\n const Tezos = new TezosToolkit(envConfig.rpcUrl);\n\tconst key = envConfig.accounts.bob.secretKey.replace('unencrypted:', '')\n\tTezos.setProvider({\n\t\tsigner: new InMemorySigner(key),\n\t });\n let contract: ContractType = undefined as unknown as ContractType;\n beforeAll(async () => {\n ${generator.generateOrigination({ formatting: { indent: 3 } }).code}\n });\n\n${\n\t\tmethodCalls.map(x => `\n it('should call ${x.name}', async () => {\n ${x.storageAccess.getStorageValueFunctionCode}\n const storageValueBefore = await ${x.storageAccess.getStorageValueFunctionName}();\n ${x.methodCall.code}\n const storageValueAfter = await ${x.storageAccess.getStorageValueFunctionName}();\n\n expect(storageValueAfter.toString()).toBe('');\n });\n`).join('')\n\t}});\n`;\n};\n\nexport default (args: RequestArgs.t) => {\n\tconst parsedArgs = args as Opts;\n\tparsedArgs.michelsonArtifact\n\t\t? ensureMichelsonExists(parsedArgs)\n\t\t\t.then(ensureSelectedPartitionExists)\n\t\t\t.then(() => parsedArgs)\n\t\t\t.then(generateContractTypes)\n\t\t\t.then(generateTestSuite)\n\t\t\t.then((outFile: string) => sendAsyncRes(`Test suite generated: ${outFile}`))\n\t\t\t.catch(sendAsyncErr)\n\t\t: sendAsyncErr(`No michelson artifact provided`);\n};\n","import { sendAsyncRes, sendErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk';\nimport { spawn } from 'child_process';\nimport { CustomRequestArgs, ensureSelectedPartitionExists, toRequestArgs } from './common';\n\nconst execCmd = (cmd: string, args: string[], env: string): Promise<number> => {\n\treturn new Promise(resolve => {\n\t\tconst child = spawn(cmd, args, {\n\t\t\tshell: true,\n\t\t\tenv: { ...process.env, FORCE_COLOR: 'true', TAQUERIA_ENV: env },\n\t\t});\n\n\t\tchild.stdout.pipe(process.stdout);\n\t\tchild.stderr.pipe(process.stderr);\n\n\t\tchild.on('close', code => {\n\t\t\tresolve(code ?? 0);\n\t\t});\n\t});\n};\n\nexport default (args: RequestArgs.t) => {\n\tconst parsedArgs = toRequestArgs(args);\n\treturn ensureSelectedPartitionExists(parsedArgs, parsedArgs.init ? true : false)\n\t\t.then(configAbsPath => {\n\t\t\tif (!parsedArgs.init) {\n\t\t\t\tconst jestArgs = ['-c', configAbsPath];\n\t\t\t\tif (parsedArgs.testPattern) {\n\t\t\t\t\tjestArgs.push('--testPathPattern', parsedArgs.testPattern);\n\t\t\t\t}\n\t\t\t\treturn execCmd('npx', ['jest', ...jestArgs], parsedArgs.env)\n\t\t\t\t\t.then(exitCode => {\n\t\t\t\t\t\tif (exitCode !== 0) process.exit(exitCode);\n\t\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn sendAsyncRes('Initialized successfully.');\n\t\t});\n};\n"],"mappings":";;;AAAA,IAAAA,mBAA8D;;;ACA9D,sBAA8D;AAC9D,mBAAgD;A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,+BAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,UAAU;AAAA,UACV,MAAM;AAAA,QACP,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,wBAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aAAa;AAAA,UACb,MAAM;AAAA,UACN,cAAc,cAAc,WAAW,EAAE,OAAO,KAAK;AAAA,QACtD,CAAC;AAAA,MACF;AAAA,MACA,aAAa;AAAA,MACb,SAAS;AAAA,IACV,CAAC;AAAA,EACF;AAAA,EACA;AAAA,EACA,aAAa;AACd,IAAI,QAAQ,IAAI;","names":["import_node_sdk","import_node_sdk","import_promises","import_path","import_node_sdk"]}
package/index.d.cts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/index.js CHANGED
@@ -160,28 +160,30 @@ var contractTestTemplate_default = (args) => {
160
160
 
161
161
  // proxy.ts
162
162
  import { sendAsyncRes as sendAsyncRes3 } from "@taqueria/node-sdk";
163
- import { execa } from "execa";
163
+ import { spawn } from "child_process";
164
164
  var execCmd = (cmd, args, env) => {
165
- var _a, _b;
166
- const child = execa(cmd, args, {
167
- shell: true,
168
- reject: false,
169
- env: { FORCE_COLOR: "true", TAQUERIA_ENV: env }
165
+ return new Promise((resolve) => {
166
+ const child = spawn(cmd, args, {
167
+ shell: true,
168
+ env: { ...process.env, FORCE_COLOR: "true", TAQUERIA_ENV: env }
169
+ });
170
+ child.stdout.pipe(process.stdout);
171
+ child.stderr.pipe(process.stderr);
172
+ child.on("close", (code) => {
173
+ resolve(code ?? 0);
174
+ });
170
175
  });
171
- (_a = child.stdout) == null ? void 0 : _a.pipe(process.stdout);
172
- (_b = child.stderr) == null ? void 0 : _b.pipe(process.stderr);
173
- return child;
174
176
  };
175
177
  var proxy_default = (args) => {
176
178
  const parsedArgs = toRequestArgs(args);
177
179
  return ensureSelectedPartitionExists(parsedArgs, parsedArgs.init ? true : false).then((configAbsPath) => {
178
180
  if (!parsedArgs.init) {
179
- const retval = parsedArgs.testPattern ? execCmd("npx", ["jest", "-c", configAbsPath, "--testPathPattern", parsedArgs.testPattern], parsedArgs.env) : execCmd("npx", ["jest", "-c", configAbsPath], parsedArgs.env);
180
- return retval.then((child) => {
181
- if (child.exitCode === 0)
182
- return;
183
- else
184
- process.exit(child.exitCode);
181
+ const jestArgs = ["-c", configAbsPath];
182
+ if (parsedArgs.testPattern) {
183
+ jestArgs.push("--testPathPattern", parsedArgs.testPattern);
184
+ }
185
+ return execCmd("npx", ["jest", ...jestArgs], parsedArgs.env).then((exitCode) => {
186
+ if (exitCode !== 0) process.exit(exitCode);
185
187
  });
186
188
  }
187
189
  return sendAsyncRes3("Initialized successfully.");
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts","common.ts","contractTestTemplate.ts","proxy.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport { CustomRequestArgs, toRequestArgs } from './common';\nimport createContractTest from './contractTestTemplate';\nimport proxy from './proxy';\n\nPlugin.create<CustomRequestArgs>(requestArgs => ({\n\tschema: '0.1',\n\tversion: '0.4.0',\n\talias: 'jest',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test [partition]',\n\t\t\tdescription: 'Setup a directory as a partition to run Jest tests',\n\t\t\taliases: ['jest'],\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'partition',\n\t\t\t\t\tdescription: 'Name of the partition for these tests',\n\t\t\t\t\tdefaultValue: 'tests',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'init',\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tdescription: 'Initializes the partition for Jest',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'testPattern',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdescription: 'Run test files that match the provided pattern',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t],\n\ttemplates: [\n\t\tTemplate.create({\n\t\t\ttemplate: 'contract-test',\n\t\t\tcommand: 'contract-test <michelsonArtifact>',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'michelsonArtifact',\n\t\t\t\t\tdescription: 'Name of the michelson contract (artifact) to generate tests for',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'partition',\n\t\t\t\t\tdescription: 'Partition to place generated test suite',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefaultValue: toRequestArgs(requestArgs).config.jest.testsRootDir,\n\t\t\t\t}),\n\t\t\t],\n\t\t\tdescription: 'Generate integration test for a contract',\n\t\t\thandler: createContractTest,\n\t\t}),\n\t],\n\tproxy,\n\tpostInstall: \"bash -c 'npm install --save-dev ts-jest @types/jest'\",\n}), process.argv);\n","import { noop, RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';\nimport { mkdir, stat, writeFile } from 'fs/promises';\nimport { defaults } from 'jest-config';\nimport { join, relative } from 'path';\nimport JestConfig from './config';\n\nexport type DefaultConfig = typeof defaults;\n\nexport interface CustomRequestArgs extends RequestArgs.t {\n\tconfig: JestConfig;\n\tpartition?: string;\n\tinit?: string;\n\ttestPattern?: string;\n}\n\nexport const toRequestArgs = (args: RequestArgs.t): CustomRequestArgs => {\n\tconst config = {\n\t\t...args.config,\n\t\tjest: {\n\t\t\ttestsRootDir: 'tests',\n\t\t},\n\t};\n\n\treturn {\n\t\t...args,\n\t\tconfig,\n\t};\n};\n\nexport const getDefaultConfig = (defaultConfig: DefaultConfig) => {\n\tconst settings = { ...defaults, preset: 'ts-jest', testEnvironment: 'node' };\n\treturn (\n\t\t`\nmodule.exports = ${JSON.stringify(settings, null, 4)}\n`\n\t);\n};\n\nexport const ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {\n\tconst jestRootConfig = getRootConfigAbspath(projectDir);\n\treturn stat(jestRootConfig)\n\t\t.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))\n\t\t.then(_ => jestRootConfig);\n};\n\nexport const getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>\n\tSanitizedAbsPath.create(\n\t\tjoin(projectDir, '.taq', 'jest.config.js'),\n\t);\n\nexport const getTestsRootDir = (config: JestConfig) => {\n\treturn config.jest.testsRootDir;\n};\n\nexport const toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `\nconst parentConfig = require('${rootConfigRelPath}')\n\nmodule.exports = {\n ...parentConfig,\n roots: [\n \"${partitionRelpath}\"\n ]\n}\n`;\n\nexport const getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);\n\nexport const getPartitionConfigAbspath = (partitionDir: string) =>\n\tSanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));\n\nexport const initPartition = (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) => {\n\treturn writeFile(\n\t\tgetPartitionConfigAbspath(partitionDir),\n\t\ttoPartitionCfg(\n\t\t\tSanitizedPath.create('./'),\n\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t),\n\t);\n};\n\nexport const ensurePartitionExists = async (\n\tpartitionDir: SanitizedAbsPath.t,\n\tprojectDir: SanitizedAbsPath.t,\n\tforceCreate = false,\n) =>\n\tensureRootConfigExists(projectDir)\n\t\t.then(_ => stat(partitionDir))\n\t\t.then(stats =>\n\t\t\tstats.isFile()\n\t\t\t\t? sendAsyncErr(`${partitionDir} is an invalid partition directory`)\n\t\t\t\t: stats\n\t\t)\n\t\t.catch(_ => mkdir(partitionDir, { recursive: true }))\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir))\n\t\t.then(partitionCfgAbsPath =>\n\t\t\tstat(partitionCfgAbsPath)\n\t\t\t\t.then(_ => forceCreate ? initPartition(partitionDir, projectDir) : undefined)\n\t\t\t\t.catch(_ => initPartition(partitionDir, projectDir))\n\t\t)\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir));\n\nexport const ensureSelectedPartitionExists = (args: CustomRequestArgs, forceCreate = false) =>\n\targs.partition\n\t\t? ensurePartitionExists(\n\t\t\tSanitizedAbsPath.create(join(args.projectDir, args.partition)),\n\t\t\tSanitizedPath.create(args.projectDir),\n\t\t\tforceCreate,\n\t\t)\n\t\t: ensurePartitionExists(\n\t\t\tSanitizedAbsPath.create(\n\t\t\t\tjoin(args.projectDir, getTestsRootDir(args.config)),\n\t\t\t),\n\t\t\tSanitizedPath.create(args.projectDir),\n\t\t\tforceCreate,\n\t\t);\n","// import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';\nimport { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { generateContractTypesProcessContractFiles } from '@taqueria/plugin-contract-types/src/cli-process.js';\nimport {\n\tcreateTestingCodeGenerator,\n\tnormalizeContractName,\n} from '@taqueria/plugin-contract-types/src/generator/testing-code-generator.js';\nimport { readFile, stat, writeFile } from 'fs/promises';\nimport { basename, dirname, join } from 'path';\nimport { CustomRequestArgs, ensureSelectedPartitionExists, getPartitionAbspath, getTestsRootDir } from './common';\n\ntype Generator = ReturnType<typeof createTestingCodeGenerator>;\n\ninterface Opts extends CustomRequestArgs {\n\treadonly michelsonArtifact?: string;\n\treadonly partition?: string;\n\treadonly name?: string;\n}\n\nconst getMichelsonAbspath = (parsedArgs: Opts) =>\n\tjoin(parsedArgs.config.artifactsDir ?? 'artifacts', parsedArgs.michelsonArtifact!);\n\nconst ensureMichelsonExists = (parsedArgs: Opts) => {\n\tconst abspath = getMichelsonAbspath(parsedArgs);\n\treturn stat(abspath)\n\t\t.then(() => parsedArgs)\n\t\t.catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run \"taq compile\"?`));\n};\n\nconst getPartition = (parsedArgs: Opts) => {\n\tconst partition = parsedArgs.partition ?? getTestsRootDir(parsedArgs.config);\n\treturn getPartitionAbspath(partition);\n};\n\nconst getTypesOutputAbspath = (parsedArgs: Opts) => join(getPartition(parsedArgs), 'types');\n\nconst generateContractTypes = (parsedArgs: Opts) =>\n\tgenerateContractTypesProcessContractFiles({\n\t\tinputTzContractDirectory: parsedArgs.config.artifactsDir ?? 'artifacts',\n\t\tinputFiles: [getMichelsonAbspath(parsedArgs)],\n\t\toutputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),\n\t\tformat: 'tz',\n\t\ttypeAliasMode: 'file',\n\t}).then(_ => parsedArgs);\n\nconst getContractName = (parsedArgs: Opts) =>\n\tparsedArgs.name\n\t\t? parsedArgs.name.trim().replace(/\\.ts$/, '')\n\t\t: basename(parsedArgs.michelsonArtifact!, '.tz');\n\nconst generateTestSuite = (parsedArgs: Opts) => {\n\tconst michelsonAbspath = getMichelsonAbspath(parsedArgs);\n\tconst contractName = getContractName(parsedArgs);\n\tconst partition = getPartition(parsedArgs);\n\tconst jestSuiteAbspath = join(partition, `${contractName}.spec.ts`);\n\n\treturn readFile(michelsonAbspath, { encoding: 'utf-8' })\n\t\t.then(contractSource => ({ contractSource, contractFormat: 'tz' as const }))\n\t\t.then(createTestingCodeGenerator)\n\t\t.then(toJest(contractName))\n\t\t.then(contents => writeFile(jestSuiteAbspath, contents, { encoding: 'utf-8' }))\n\t\t.then(() => jestSuiteAbspath);\n};\n\nconst toJest = (contractName: string) => (generator: Generator) => {\n\tconst methodCalls = generator.methods.map(m => ({\n\t\tname: m.name,\n\t\tmethodCall: generator.generateMethodCall({\n\t\t\tmethodName: m.name,\n\t\t\tformatting: {\n\t\t\t\tindent: 2,\n\t\t\t},\n\t\t}),\n\t\tstorageAccess: generator.generateStorageAccess({ storagePath: '' }),\n\t}));\n\treturn `\nimport { TezosToolkit } from '@taquito/taquito';\nimport { stringToBytes } from '@taquito/utils';\nimport { tas } from './types/type-aliases';\nimport { InMemorySigner } from '@taquito/signer';\nimport { ${normalizeContractName(contractName)}ContractType as ContractType } from './types/${contractName}.types';\nimport { ${normalizeContractName(contractName)}Code as ContractCode } from './types/${contractName}.code';\n\njest.setTimeout(20000)\n\ndescribe('${contractName}', () => {\n\tconst currentEnv = process.env.TAQUERIA_ENV || 'development';\n\tconst envConfig = require('../.taq/config.local.' + currentEnv + '.json')\n const Tezos = new TezosToolkit(envConfig.rpcUrl);\n\tconst key = envConfig.accounts.bob.secretKey.replace('unencrypted:', '')\n\tTezos.setProvider({\n\t\tsigner: new InMemorySigner(key),\n\t });\n let contract: ContractType = undefined as unknown as ContractType;\n beforeAll(async () => {\n ${generator.generateOrigination({ formatting: { indent: 3 } }).code}\n });\n\n${\n\t\tmethodCalls.map(x => `\n it('should call ${x.name}', async () => {\n ${x.storageAccess.getStorageValueFunctionCode}\n const storageValueBefore = await ${x.storageAccess.getStorageValueFunctionName}();\n ${x.methodCall.code}\n const storageValueAfter = await ${x.storageAccess.getStorageValueFunctionName}();\n\n expect(storageValueAfter.toString()).toBe('');\n });\n`).join('')\n\t}});\n`;\n};\n\nexport default (args: RequestArgs.t) => {\n\tconst parsedArgs = args as Opts;\n\tparsedArgs.michelsonArtifact\n\t\t? ensureMichelsonExists(parsedArgs)\n\t\t\t.then(ensureSelectedPartitionExists)\n\t\t\t.then(() => parsedArgs)\n\t\t\t.then(generateContractTypes)\n\t\t\t.then(generateTestSuite)\n\t\t\t.then((outFile: string) => sendAsyncRes(`Test suite generated: ${outFile}`))\n\t\t\t.catch(sendAsyncErr)\n\t\t: sendAsyncErr(`No michelson artifact provided`);\n};\n","import { sendAsyncRes, sendErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk';\nimport { execa } from 'execa';\nimport { CustomRequestArgs, ensureSelectedPartitionExists, toRequestArgs } from './common';\n\nconst execCmd = (cmd: string, args: string[], env: string) => {\n\tconst child = execa(cmd, args, {\n\t\tshell: true,\n\t\treject: false,\n\t\tenv: { FORCE_COLOR: 'true', TAQUERIA_ENV: env },\n\t});\n\n\tchild.stdout?.pipe(process.stdout);\n\tchild.stderr?.pipe(process.stderr);\n\n\treturn child;\n};\nexport default (args: RequestArgs.t) => {\n\tconst parsedArgs = toRequestArgs(args);\n\treturn ensureSelectedPartitionExists(parsedArgs, parsedArgs.init ? true : false)\n\t\t.then(configAbsPath => {\n\t\t\tif (!parsedArgs.init) {\n\t\t\t\tconst retval = parsedArgs.testPattern\n\t\t\t\t\t? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', parsedArgs.testPattern], parsedArgs.env)\n\t\t\t\t\t: execCmd('npx', ['jest', '-c', configAbsPath], parsedArgs.env);\n\t\t\t\treturn retval.then(child => {\n\t\t\t\t\tif (child.exitCode === 0) return;\n\t\t\t\t\telse process.exit(child.exitCode);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn sendAsyncRes('Initialized successfully.');\n\t\t});\n};\n"],"mappings":";AAAA,SAAS,QAAQ,QAAQ,eAAe,MAAM,gBAAgB;;;ACA9D,SAA4B,oBAAkC;AAC9D,SAAS,kBAAkB,qBAAqB;AAChD,SAAS,OAAO,MAAM,iBAAiB;AACvC,SAAS,gBAAgB;AACzB,SAAS,MAAM,gBAAgB;AAYxB,IAAM,gBAAgB,CAAC,SAA2C;AACxE,QAAM,SAAS;AAAA,IACd,GAAG,KAAK;AAAA,IACR,MAAM;AAAA,MACL,cAAc;AAAA,IACf;AAAA,EACD;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH;AAAA,EACD;AACD;AAEO,IAAM,mBAAmB,CAAC,kBAAiC;AACjE,QAAM,WAAW,EAAE,GAAG,UAAU,QAAQ,WAAW,iBAAiB,OAAO;AAC3E,SACC;AAAA,mBACiB,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,IAAI,QAAQ,IAAI;","names":["sendAsyncErr","sendAsyncRes","stat","writeFile","join","join","stat","writeFile","sendAsyncRes","sendAsyncErr","sendAsyncRes","sendAsyncRes"]}
1
+ {"version":3,"sources":["index.ts","common.ts","contractTestTemplate.ts","proxy.ts"],"sourcesContent":["import { Option, Plugin, PositionalArg, Task, Template } from '@taqueria/node-sdk';\nimport { CustomRequestArgs, toRequestArgs } from './common';\nimport createContractTest from './contractTestTemplate';\nimport proxy from './proxy';\n\nPlugin.create<CustomRequestArgs>(requestArgs => ({\n\tschema: '0.1',\n\tversion: '0.4.0',\n\talias: 'jest',\n\ttasks: [\n\t\tTask.create({\n\t\t\ttask: 'test',\n\t\t\tcommand: 'test [partition]',\n\t\t\tdescription: 'Setup a directory as a partition to run Jest tests',\n\t\t\taliases: ['jest'],\n\t\t\thandler: 'proxy',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'partition',\n\t\t\t\t\tdescription: 'Name of the partition for these tests',\n\t\t\t\t\tdefaultValue: 'tests',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'init',\n\t\t\t\t\tshortFlag: 'i',\n\t\t\t\t\tdescription: 'Initializes the partition for Jest',\n\t\t\t\t\tboolean: true,\n\t\t\t\t}),\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'testPattern',\n\t\t\t\t\tshortFlag: 't',\n\t\t\t\t\tdescription: 'Run test files that match the provided pattern',\n\t\t\t\t}),\n\t\t\t],\n\t\t}),\n\t],\n\ttemplates: [\n\t\tTemplate.create({\n\t\t\ttemplate: 'contract-test',\n\t\t\tcommand: 'contract-test <michelsonArtifact>',\n\t\t\tpositionals: [\n\t\t\t\tPositionalArg.create({\n\t\t\t\t\tplaceholder: 'michelsonArtifact',\n\t\t\t\t\tdescription: 'Name of the michelson contract (artifact) to generate tests for',\n\t\t\t\t\trequired: true,\n\t\t\t\t\ttype: 'string',\n\t\t\t\t}),\n\t\t\t],\n\t\t\toptions: [\n\t\t\t\tOption.create({\n\t\t\t\t\tflag: 'partition',\n\t\t\t\t\tdescription: 'Partition to place generated test suite',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdefaultValue: toRequestArgs(requestArgs).config.jest.testsRootDir,\n\t\t\t\t}),\n\t\t\t],\n\t\t\tdescription: 'Generate integration test for a contract',\n\t\t\thandler: createContractTest,\n\t\t}),\n\t],\n\tproxy,\n\tpostInstall: \"bash -c 'npm install --save-dev ts-jest @types/jest'\",\n}), process.argv);\n","import { noop, RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';\nimport { mkdir, stat, writeFile } from 'fs/promises';\nimport { defaults } from 'jest-config';\nimport { join, relative } from 'path';\nimport JestConfig from './config';\n\nexport type DefaultConfig = typeof defaults;\n\nexport interface CustomRequestArgs extends RequestArgs.t {\n\tconfig: JestConfig;\n\tpartition?: string;\n\tinit?: string;\n\ttestPattern?: string;\n}\n\nexport const toRequestArgs = (args: RequestArgs.t): CustomRequestArgs => {\n\tconst config = {\n\t\t...args.config,\n\t\tjest: {\n\t\t\ttestsRootDir: 'tests',\n\t\t},\n\t};\n\n\treturn {\n\t\t...args,\n\t\tconfig,\n\t};\n};\n\nexport const getDefaultConfig = (defaultConfig: DefaultConfig) => {\n\tconst settings = { ...defaults, preset: 'ts-jest', testEnvironment: 'node' };\n\treturn (\n\t\t`\nmodule.exports = ${JSON.stringify(settings, null, 4)}\n`\n\t);\n};\n\nexport const ensureRootConfigExists = (projectDir: SanitizedAbsPath.t) => {\n\tconst jestRootConfig = getRootConfigAbspath(projectDir);\n\treturn stat(jestRootConfig)\n\t\t.catch(_ => writeFile(jestRootConfig, getDefaultConfig(defaults)))\n\t\t.then(_ => jestRootConfig);\n};\n\nexport const getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>\n\tSanitizedAbsPath.create(\n\t\tjoin(projectDir, '.taq', 'jest.config.js'),\n\t);\n\nexport const getTestsRootDir = (config: JestConfig) => {\n\treturn config.jest.testsRootDir;\n};\n\nexport const toPartitionCfg = (partitionRelpath: SanitizedPath.t, rootConfigRelPath: SanitizedPath.t) => `\nconst parentConfig = require('${rootConfigRelPath}')\n\nmodule.exports = {\n ...parentConfig,\n roots: [\n \"${partitionRelpath}\"\n ]\n}\n`;\n\nexport const getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.create(partitionDir);\n\nexport const getPartitionConfigAbspath = (partitionDir: string) =>\n\tSanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));\n\nexport const initPartition = (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) => {\n\treturn writeFile(\n\t\tgetPartitionConfigAbspath(partitionDir),\n\t\ttoPartitionCfg(\n\t\t\tSanitizedPath.create('./'),\n\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t),\n\t);\n};\n\nexport const ensurePartitionExists = async (\n\tpartitionDir: SanitizedAbsPath.t,\n\tprojectDir: SanitizedAbsPath.t,\n\tforceCreate = false,\n) =>\n\tensureRootConfigExists(projectDir)\n\t\t.then(_ => stat(partitionDir))\n\t\t.then(stats =>\n\t\t\tstats.isFile()\n\t\t\t\t? sendAsyncErr(`${partitionDir} is an invalid partition directory`)\n\t\t\t\t: stats\n\t\t)\n\t\t.catch(_ => mkdir(partitionDir, { recursive: true }))\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir))\n\t\t.then(partitionCfgAbsPath =>\n\t\t\tstat(partitionCfgAbsPath)\n\t\t\t\t.then(_ => forceCreate ? initPartition(partitionDir, projectDir) : undefined)\n\t\t\t\t.catch(_ => initPartition(partitionDir, projectDir))\n\t\t)\n\t\t.then(_ => getPartitionConfigAbspath(partitionDir));\n\nexport const ensureSelectedPartitionExists = (args: CustomRequestArgs, forceCreate = false) =>\n\targs.partition\n\t\t? ensurePartitionExists(\n\t\t\tSanitizedAbsPath.create(join(args.projectDir, args.partition)),\n\t\t\tSanitizedPath.create(args.projectDir),\n\t\t\tforceCreate,\n\t\t)\n\t\t: ensurePartitionExists(\n\t\t\tSanitizedAbsPath.create(\n\t\t\t\tjoin(args.projectDir, getTestsRootDir(args.config)),\n\t\t\t),\n\t\t\tSanitizedPath.create(args.projectDir),\n\t\t\tforceCreate,\n\t\t);\n","// import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';\nimport { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { generateContractTypesProcessContractFiles } from '@taqueria/plugin-contract-types/src/cli-process.js';\nimport {\n\tcreateTestingCodeGenerator,\n\tnormalizeContractName,\n} from '@taqueria/plugin-contract-types/src/generator/testing-code-generator.js';\nimport { readFile, stat, writeFile } from 'fs/promises';\nimport { basename, dirname, join } from 'path';\nimport { CustomRequestArgs, ensureSelectedPartitionExists, getPartitionAbspath, getTestsRootDir } from './common';\n\ntype Generator = ReturnType<typeof createTestingCodeGenerator>;\n\ninterface Opts extends CustomRequestArgs {\n\treadonly michelsonArtifact?: string;\n\treadonly partition?: string;\n\treadonly name?: string;\n}\n\nconst getMichelsonAbspath = (parsedArgs: Opts) =>\n\tjoin(parsedArgs.config.artifactsDir ?? 'artifacts', parsedArgs.michelsonArtifact!);\n\nconst ensureMichelsonExists = (parsedArgs: Opts) => {\n\tconst abspath = getMichelsonAbspath(parsedArgs);\n\treturn stat(abspath)\n\t\t.then(() => parsedArgs)\n\t\t.catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run \"taq compile\"?`));\n};\n\nconst getPartition = (parsedArgs: Opts) => {\n\tconst partition = parsedArgs.partition ?? getTestsRootDir(parsedArgs.config);\n\treturn getPartitionAbspath(partition);\n};\n\nconst getTypesOutputAbspath = (parsedArgs: Opts) => join(getPartition(parsedArgs), 'types');\n\nconst generateContractTypes = (parsedArgs: Opts) =>\n\tgenerateContractTypesProcessContractFiles({\n\t\tinputTzContractDirectory: parsedArgs.config.artifactsDir ?? 'artifacts',\n\t\tinputFiles: [getMichelsonAbspath(parsedArgs)],\n\t\toutputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),\n\t\tformat: 'tz',\n\t\ttypeAliasMode: 'file',\n\t}).then(_ => parsedArgs);\n\nconst getContractName = (parsedArgs: Opts) =>\n\tparsedArgs.name\n\t\t? parsedArgs.name.trim().replace(/\\.ts$/, '')\n\t\t: basename(parsedArgs.michelsonArtifact!, '.tz');\n\nconst generateTestSuite = (parsedArgs: Opts) => {\n\tconst michelsonAbspath = getMichelsonAbspath(parsedArgs);\n\tconst contractName = getContractName(parsedArgs);\n\tconst partition = getPartition(parsedArgs);\n\tconst jestSuiteAbspath = join(partition, `${contractName}.spec.ts`);\n\n\treturn readFile(michelsonAbspath, { encoding: 'utf-8' })\n\t\t.then(contractSource => ({ contractSource, contractFormat: 'tz' as const }))\n\t\t.then(createTestingCodeGenerator)\n\t\t.then(toJest(contractName))\n\t\t.then(contents => writeFile(jestSuiteAbspath, contents, { encoding: 'utf-8' }))\n\t\t.then(() => jestSuiteAbspath);\n};\n\nconst toJest = (contractName: string) => (generator: Generator) => {\n\tconst methodCalls = generator.methods.map(m => ({\n\t\tname: m.name,\n\t\tmethodCall: generator.generateMethodCall({\n\t\t\tmethodName: m.name,\n\t\t\tformatting: {\n\t\t\t\tindent: 2,\n\t\t\t},\n\t\t}),\n\t\tstorageAccess: generator.generateStorageAccess({ storagePath: '' }),\n\t}));\n\treturn `\nimport { TezosToolkit } from '@taquito/taquito';\nimport { stringToBytes } from '@taquito/utils';\nimport { tas } from './types/type-aliases';\nimport { InMemorySigner } from '@taquito/signer';\nimport { ${normalizeContractName(contractName)}ContractType as ContractType } from './types/${contractName}.types';\nimport { ${normalizeContractName(contractName)}Code as ContractCode } from './types/${contractName}.code';\n\njest.setTimeout(20000)\n\ndescribe('${contractName}', () => {\n\tconst currentEnv = process.env.TAQUERIA_ENV || 'development';\n\tconst envConfig = require('../.taq/config.local.' + currentEnv + '.json')\n const Tezos = new TezosToolkit(envConfig.rpcUrl);\n\tconst key = envConfig.accounts.bob.secretKey.replace('unencrypted:', '')\n\tTezos.setProvider({\n\t\tsigner: new InMemorySigner(key),\n\t });\n let contract: ContractType = undefined as unknown as ContractType;\n beforeAll(async () => {\n ${generator.generateOrigination({ formatting: { indent: 3 } }).code}\n });\n\n${\n\t\tmethodCalls.map(x => `\n it('should call ${x.name}', async () => {\n ${x.storageAccess.getStorageValueFunctionCode}\n const storageValueBefore = await ${x.storageAccess.getStorageValueFunctionName}();\n ${x.methodCall.code}\n const storageValueAfter = await ${x.storageAccess.getStorageValueFunctionName}();\n\n expect(storageValueAfter.toString()).toBe('');\n });\n`).join('')\n\t}});\n`;\n};\n\nexport default (args: RequestArgs.t) => {\n\tconst parsedArgs = args as Opts;\n\tparsedArgs.michelsonArtifact\n\t\t? ensureMichelsonExists(parsedArgs)\n\t\t\t.then(ensureSelectedPartitionExists)\n\t\t\t.then(() => parsedArgs)\n\t\t\t.then(generateContractTypes)\n\t\t\t.then(generateTestSuite)\n\t\t\t.then((outFile: string) => sendAsyncRes(`Test suite generated: ${outFile}`))\n\t\t\t.catch(sendAsyncErr)\n\t\t: sendAsyncErr(`No michelson artifact provided`);\n};\n","import { sendAsyncRes, sendErr } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk';\nimport { spawn } from 'child_process';\nimport { CustomRequestArgs, ensureSelectedPartitionExists, toRequestArgs } from './common';\n\nconst execCmd = (cmd: string, args: string[], env: string): Promise<number> => {\n\treturn new Promise(resolve => {\n\t\tconst child = spawn(cmd, args, {\n\t\t\tshell: true,\n\t\t\tenv: { ...process.env, FORCE_COLOR: 'true', TAQUERIA_ENV: env },\n\t\t});\n\n\t\tchild.stdout.pipe(process.stdout);\n\t\tchild.stderr.pipe(process.stderr);\n\n\t\tchild.on('close', code => {\n\t\t\tresolve(code ?? 0);\n\t\t});\n\t});\n};\n\nexport default (args: RequestArgs.t) => {\n\tconst parsedArgs = toRequestArgs(args);\n\treturn ensureSelectedPartitionExists(parsedArgs, parsedArgs.init ? true : false)\n\t\t.then(configAbsPath => {\n\t\t\tif (!parsedArgs.init) {\n\t\t\t\tconst jestArgs = ['-c', configAbsPath];\n\t\t\t\tif (parsedArgs.testPattern) {\n\t\t\t\t\tjestArgs.push('--testPathPattern', parsedArgs.testPattern);\n\t\t\t\t}\n\t\t\t\treturn execCmd('npx', ['jest', ...jestArgs], parsedArgs.env)\n\t\t\t\t\t.then(exitCode => {\n\t\t\t\t\t\tif (exitCode !== 0) process.exit(exitCode);\n\t\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn sendAsyncRes('Initialized successfully.');\n\t\t});\n};\n"],"mappings":";AAAA,SAAS,QAAQ,QAAQ,eAAe,MAAM,gBAAgB;;;ACA9D,SAA4B,oBAAkC;AAC9D,SAAS,kBAAkB,qBAAqB;AAChD,SAAS,OAAO,MAAM,iBAAiB;AACvC,SAAS,gBAAgB;AACzB,SAAS,MAAM,gBAAgB;AAYxB,IAAM,gBAAgB,CAAC,SAA2C;AACxE,QAAM,SAAS;AAAA,IACd,GAAG,KAAK;AAAA,IACR,MAAM;AAAA,MACL,cAAc;AAAA,IACf;AAAA,EACD;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH;AAAA,EACD;AACD;AAEO,IAAM,mBAAmB,CAAC,kBAAiC;AACjE,QAAM,WAAW,EAAE,GAAG,UAAU,QAAQ,WAAW,iBAAiB,OAAO;AAC3E,SACC;AAAA,mBACiB,KAAK,UAAU,UAAU,MAAM,CAAC,CAAC;AAAA;AAGpD;AAEO,IAAM,yBAAyB,CAAC,eAAmC;AACzE,QAAM,iBAAiB,qBAAqB,UAAU;AACtD,SAAO,KAAK,cAAc,EACxB,MAAM,OAAK,UAAU,gBAAgB,iBAAiB,QAAQ,CAAC,CAAC,EAChE,KAAK,OAAK,cAAc;AAC3B;AAEO,IAAM,uBAAuB,CAAC,eACpC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AAA,EAChD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,IACN,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS,CAAC,MAAM;AAAA,MAChB,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,cAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,cAAc;AAAA,UACd,MAAM;AAAA,QACP,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aAAa;AAAA,UACb,SAAS;AAAA,QACV,CAAC;AAAA,QACD,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,EACF;AAAA,EACA,WAAW;AAAA,IACV,SAAS,OAAO;AAAA,MACf,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,cAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,UAAU;AAAA,UACV,MAAM;AAAA,QACP,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aAAa;AAAA,UACb,MAAM;AAAA,UACN,cAAc,cAAc,WAAW,EAAE,OAAO,KAAK;AAAA,QACtD,CAAC;AAAA,MACF;AAAA,MACA,aAAa;AAAA,MACb,SAAS;AAAA,IACV,CAAC;AAAA,EACF;AAAA,EACA;AAAA,EACA,aAAa;AACd,IAAI,QAAQ,IAAI;","names":["sendAsyncErr","sendAsyncRes","stat","writeFile","join","join","stat","writeFile","sendAsyncRes","sendAsyncErr","sendAsyncRes","sendAsyncRes"]}
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
1
  {
2
- "name": "@taqueria/plugin-jest",
3
- "version": "0.56.15",
4
- "main": "index.cjs",
5
- "module": "index.js",
6
- "source": "index.ts",
7
- "type": "module",
8
- "description": "A plugin for Taqueria providing automated testing using the Jest Testing Framework",
9
- "keywords": [
10
- "taqueria",
11
- "plugin",
12
- "jest",
13
- "testing",
14
- "tdd",
15
- "pinnaclelabs",
16
- "pinnacle-labs",
17
- "tezos"
18
- ],
19
- "scripts": {
20
- "build": "npx tsc -noEmit -p ./tsconfig.json && npx tsup"
21
- },
22
- "author": "Taqueria",
23
- "license": "Apache-2.0",
24
- "repository": {
25
- "type": "git",
26
- "url": "https://github.com/tezostaqueria/taqueria.git",
27
- "directory": "taqueria-plugin-jest"
28
- },
29
- "dependencies": {
30
- "@taqueria/node-sdk": "^0.56.15",
31
- "@taqueria/plugin-contract-types": "^0.56.15",
32
- "@taquito/signer": "^20.0.1",
33
- "@taquito/taquito": "^20.0.1",
34
- "@taquito/utils": "^20.0.1",
35
- "@types/jest": "^29.5.11",
36
- "async-retry": "^1.3.3",
37
- "bignumber.js": "^9.1.2",
38
- "execa": "^8.0.1",
39
- "fast-glob": "^3.3.2",
40
- "jest-config": "^29.7.0"
41
- },
42
- "devDependencies": {
43
- "@types/async-retry": "^1.4.8",
44
- "tsup": "^8.0.1",
45
- "typescript": "^5.3.3"
46
- },
47
- "tsup": {
48
- "entry": [
49
- "index.ts"
50
- ],
51
- "sourcemap": true,
52
- "target": "node16",
53
- "outDir": "./",
54
- "dts": true,
55
- "clean": false,
56
- "skipNodeModulesBundle": true,
57
- "platform": "node",
58
- "format": [
59
- "esm",
60
- "cjs"
61
- ]
62
- },
63
- "gitHead": "ff58a2fc06ad233869ad6be574093c8b3b272e2e"
64
- }
2
+ "name": "@taqueria/plugin-jest",
3
+ "version": "0.57.9",
4
+ "main": "index.cjs",
5
+ "module": "index.js",
6
+ "source": "index.ts",
7
+ "type": "module",
8
+ "description": "A plugin for Taqueria providing automated testing using the Jest Testing Framework",
9
+ "keywords": [
10
+ "taqueria",
11
+ "plugin",
12
+ "jest",
13
+ "testing",
14
+ "tdd",
15
+ "pinnaclelabs",
16
+ "pinnacle-labs",
17
+ "tezos"
18
+ ],
19
+ "author": "Taqueria",
20
+ "license": "Apache-2.0",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/tezostaqueria/taqueria.git",
24
+ "directory": "taqueria-plugin-jest"
25
+ },
26
+ "dependencies": {
27
+ "@taquito/signer": "^21.0.0-beta.0",
28
+ "@taquito/taquito": "^21.0.0-beta.0",
29
+ "@taquito/utils": "^21.0.0-beta.0",
30
+ "@types/jest": "^29.5.11",
31
+ "async-retry": "^1.3.3",
32
+ "bignumber.js": "^9.1.2",
33
+ "fast-glob": "^3.3.2",
34
+ "jest-config": "^29.7.0",
35
+ "@taqueria/node-sdk": "0.57.9",
36
+ "@taqueria/plugin-contract-types": "0.57.9"
37
+ },
38
+ "devDependencies": {
39
+ "@types/async-retry": "^1.4.8",
40
+ "@types/node": "^22.7.4",
41
+ "tsup": "^8.3.0",
42
+ "typescript": "^5.6.2"
43
+ },
44
+ "tsup": {
45
+ "entry": [
46
+ "index.ts"
47
+ ],
48
+ "sourcemap": true,
49
+ "target": "node16",
50
+ "outDir": "./",
51
+ "dts": true,
52
+ "clean": false,
53
+ "skipNodeModulesBundle": true,
54
+ "platform": "node",
55
+ "format": [
56
+ "esm",
57
+ "cjs"
58
+ ]
59
+ },
60
+ "gitHead": "ff58a2fc06ad233869ad6be574093c8b3b272e2e",
61
+ "scripts": {
62
+ "build": "npx tsc -noEmit -p ./tsconfig.json && npx tsup"
63
+ }
64
+ }
package/proxy.ts CHANGED
@@ -1,32 +1,37 @@
1
1
  import { sendAsyncRes, sendErr } from '@taqueria/node-sdk';
2
2
  import { RequestArgs } from '@taqueria/node-sdk';
3
- import { execa } from 'execa';
3
+ import { spawn } from 'child_process';
4
4
  import { CustomRequestArgs, ensureSelectedPartitionExists, toRequestArgs } from './common';
5
5
 
6
- const execCmd = (cmd: string, args: string[], env: string) => {
7
- const child = execa(cmd, args, {
8
- shell: true,
9
- reject: false,
10
- env: { FORCE_COLOR: 'true', TAQUERIA_ENV: env },
11
- });
6
+ const execCmd = (cmd: string, args: string[], env: string): Promise<number> => {
7
+ return new Promise(resolve => {
8
+ const child = spawn(cmd, args, {
9
+ shell: true,
10
+ env: { ...process.env, FORCE_COLOR: 'true', TAQUERIA_ENV: env },
11
+ });
12
12
 
13
- child.stdout?.pipe(process.stdout);
14
- child.stderr?.pipe(process.stderr);
13
+ child.stdout.pipe(process.stdout);
14
+ child.stderr.pipe(process.stderr);
15
15
 
16
- return child;
16
+ child.on('close', code => {
17
+ resolve(code ?? 0);
18
+ });
19
+ });
17
20
  };
21
+
18
22
  export default (args: RequestArgs.t) => {
19
23
  const parsedArgs = toRequestArgs(args);
20
24
  return ensureSelectedPartitionExists(parsedArgs, parsedArgs.init ? true : false)
21
25
  .then(configAbsPath => {
22
26
  if (!parsedArgs.init) {
23
- const retval = parsedArgs.testPattern
24
- ? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', parsedArgs.testPattern], parsedArgs.env)
25
- : execCmd('npx', ['jest', '-c', configAbsPath], parsedArgs.env);
26
- return retval.then(child => {
27
- if (child.exitCode === 0) return;
28
- else process.exit(child.exitCode);
29
- });
27
+ const jestArgs = ['-c', configAbsPath];
28
+ if (parsedArgs.testPattern) {
29
+ jestArgs.push('--testPathPattern', parsedArgs.testPattern);
30
+ }
31
+ return execCmd('npx', ['jest', ...jestArgs], parsedArgs.env)
32
+ .then(exitCode => {
33
+ if (exitCode !== 0) process.exit(exitCode);
34
+ });
30
35
  }
31
36
 
32
37
  return sendAsyncRes('Initialized successfully.');
package/tsconfig.json CHANGED
@@ -102,5 +102,10 @@
102
102
  /* Completeness */
103
103
  // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
104
104
  "skipLibCheck": true /* Skip type checking all .d.ts files. */
105
- }
105
+ },
106
+ "references": [
107
+ {
108
+ "path": "../taqueria-sdk"
109
+ }
110
+ ]
106
111
  }