@taqueria/plugin-jest 0.50.0 → 0.50.2
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/contractTestTemplate.ts +6 -5
- package/index.cjs +11 -9
- package/index.cjs.map +1 -1
- package/index.js +11 -9
- package/index.js.map +1 -1
- package/index.ts +1 -0
- package/package.json +4 -6
- package/proxy.ts +4 -4
package/contractTestTemplate.ts
CHANGED
|
@@ -75,18 +75,19 @@ const toJest = (contractName: string) => (generator: Generator) => {
|
|
|
75
75
|
}));
|
|
76
76
|
return `
|
|
77
77
|
import { TezosToolkit } from '@taquito/taquito';
|
|
78
|
-
import {
|
|
78
|
+
import { stringToBytes } from '@taquito/utils';
|
|
79
79
|
import { tas } from './types/type-aliases';
|
|
80
|
-
import { InMemorySigner
|
|
80
|
+
import { InMemorySigner } from '@taquito/signer';
|
|
81
81
|
import { ${normalizeContractName(contractName)}ContractType as ContractType } from './types/${contractName}.types';
|
|
82
82
|
import { ${normalizeContractName(contractName)}Code as ContractCode } from './types/${contractName}.code';
|
|
83
83
|
|
|
84
84
|
jest.setTimeout(20000)
|
|
85
85
|
|
|
86
86
|
describe('${contractName}', () => {
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
const currentEnv = process.env.TAQUERIA_ENV || 'development';
|
|
88
|
+
const envConfig = require('../.taq/config.local.' + currentEnv + '.json')
|
|
89
|
+
const Tezos = new TezosToolkit(envConfig.rpcUrl);
|
|
90
|
+
const key = envConfig.accounts.bob.secretKey.replace('unencrypted:', '')
|
|
90
91
|
Tezos.setProvider({
|
|
91
92
|
signer: new InMemorySigner(key),
|
|
92
93
|
});
|
package/index.cjs
CHANGED
|
@@ -119,18 +119,19 @@ var toJest = (contractName) => (generator) => {
|
|
|
119
119
|
}));
|
|
120
120
|
return `
|
|
121
121
|
import { TezosToolkit } from '@taquito/taquito';
|
|
122
|
-
import {
|
|
122
|
+
import { stringToBytes } from '@taquito/utils';
|
|
123
123
|
import { tas } from './types/type-aliases';
|
|
124
|
-
import { InMemorySigner
|
|
124
|
+
import { InMemorySigner } from '@taquito/signer';
|
|
125
125
|
import { ${(0, import_testing_code_generator.normalizeContractName)(contractName)}ContractType as ContractType } from './types/${contractName}.types';
|
|
126
126
|
import { ${(0, import_testing_code_generator.normalizeContractName)(contractName)}Code as ContractCode } from './types/${contractName}.code';
|
|
127
127
|
|
|
128
128
|
jest.setTimeout(20000)
|
|
129
129
|
|
|
130
130
|
describe('${contractName}', () => {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
const currentEnv = process.env.TAQUERIA_ENV || 'development';
|
|
132
|
+
const envConfig = require('../.taq/config.local.' + currentEnv + '.json')
|
|
133
|
+
const Tezos = new TezosToolkit(envConfig.rpcUrl);
|
|
134
|
+
const key = envConfig.accounts.bob.secretKey.replace('unencrypted:', '')
|
|
134
135
|
Tezos.setProvider({
|
|
135
136
|
signer: new InMemorySigner(key),
|
|
136
137
|
});
|
|
@@ -159,12 +160,12 @@ var contractTestTemplate_default = (args) => {
|
|
|
159
160
|
// proxy.ts
|
|
160
161
|
var import_node_sdk3 = require("@taqueria/node-sdk");
|
|
161
162
|
var import_execa = require("execa");
|
|
162
|
-
var execCmd = (cmd, args) => {
|
|
163
|
+
var execCmd = (cmd, args, env) => {
|
|
163
164
|
var _a, _b;
|
|
164
165
|
const child = (0, import_execa.execa)(cmd, args, {
|
|
165
166
|
shell: true,
|
|
166
167
|
reject: false,
|
|
167
|
-
env: { FORCE_COLOR: "true" }
|
|
168
|
+
env: { FORCE_COLOR: "true", TAQUERIA_ENV: env }
|
|
168
169
|
});
|
|
169
170
|
(_a = child.stdout) == null ? void 0 : _a.pipe(process.stdout);
|
|
170
171
|
(_b = child.stderr) == null ? void 0 : _b.pipe(process.stderr);
|
|
@@ -174,7 +175,7 @@ var proxy_default = (args) => {
|
|
|
174
175
|
const parsedArgs = toRequestArgs(args);
|
|
175
176
|
return ensureSelectedPartitionExists(parsedArgs, parsedArgs.init ? true : false).then((configAbsPath) => {
|
|
176
177
|
if (!parsedArgs.init) {
|
|
177
|
-
const retval = parsedArgs.testPattern ? execCmd("npx", ["jest", "-c", configAbsPath, "--testPathPattern", parsedArgs.testPattern]) : execCmd("npx", ["jest", "-c", configAbsPath]);
|
|
178
|
+
const retval = parsedArgs.testPattern ? execCmd("npx", ["jest", "-c", configAbsPath, "--testPathPattern", parsedArgs.testPattern], parsedArgs.env) : execCmd("npx", ["jest", "-c", configAbsPath], parsedArgs.env);
|
|
178
179
|
return retval.then((child) => {
|
|
179
180
|
if (child.exitCode === 0)
|
|
180
181
|
return;
|
|
@@ -245,6 +246,7 @@ import_node_sdk4.Plugin.create((requestArgs) => ({
|
|
|
245
246
|
handler: contractTestTemplate_default
|
|
246
247
|
})
|
|
247
248
|
],
|
|
248
|
-
proxy: proxy_default
|
|
249
|
+
proxy: proxy_default,
|
|
250
|
+
postInstall: "bash -c 'npm install --save-dev ts-jest @types/jest'"
|
|
249
251
|
}), process.argv);
|
|
250
252
|
//# sourceMappingURL=index.cjs.map
|
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}), 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 { char2Bytes } from '@taquito/utils';\nimport { tas } from './types/type-aliases';\nimport { InMemorySigner, importKey } 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 config = require('../.taq/config.json')\n const Tezos = new TezosToolkit(config.sandbox.local.rpcUrl);\n\tconst key = config.sandbox.local.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[]) => {\n\tconst child = execa(cmd, args, {\n\t\tshell: true,\n\t\treject: false,\n\t\tenv: { FORCE_COLOR: 'true' },\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])\n\t\t\t\t\t: execCmd('npx', ['jest', '-c', configAbsPath]);\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,QAA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,MACjC,CAAC;AAAA,IACF;AAEA,eAAO,+BAAa,2BAA2B;AAAA,EAChD,CAAC;AACH;;;AH5BA,wBAAO,OAA0B,kBAAgB;AAAA,EAChD,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,IACN,sBAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS,CAAC,MAAM;AAAA,MAChB,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,+BAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,cAAc;AAAA,UACd,MAAM;AAAA,QACP,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;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 { 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,kBAAmC,sBAAuC;AAAA,gCACzE,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA,WAKtC,gBAAgB;AAAA;AAAA;AAAA;AAKpB,IAAM,sBAAsB,CAAC,iBAAy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A,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"]}
|
package/index.js
CHANGED
|
@@ -120,18 +120,19 @@ var toJest = (contractName) => (generator) => {
|
|
|
120
120
|
}));
|
|
121
121
|
return `
|
|
122
122
|
import { TezosToolkit } from '@taquito/taquito';
|
|
123
|
-
import {
|
|
123
|
+
import { stringToBytes } from '@taquito/utils';
|
|
124
124
|
import { tas } from './types/type-aliases';
|
|
125
|
-
import { InMemorySigner
|
|
125
|
+
import { InMemorySigner } from '@taquito/signer';
|
|
126
126
|
import { ${normalizeContractName(contractName)}ContractType as ContractType } from './types/${contractName}.types';
|
|
127
127
|
import { ${normalizeContractName(contractName)}Code as ContractCode } from './types/${contractName}.code';
|
|
128
128
|
|
|
129
129
|
jest.setTimeout(20000)
|
|
130
130
|
|
|
131
131
|
describe('${contractName}', () => {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
const currentEnv = process.env.TAQUERIA_ENV || 'development';
|
|
133
|
+
const envConfig = require('../.taq/config.local.' + currentEnv + '.json')
|
|
134
|
+
const Tezos = new TezosToolkit(envConfig.rpcUrl);
|
|
135
|
+
const key = envConfig.accounts.bob.secretKey.replace('unencrypted:', '')
|
|
135
136
|
Tezos.setProvider({
|
|
136
137
|
signer: new InMemorySigner(key),
|
|
137
138
|
});
|
|
@@ -160,12 +161,12 @@ var contractTestTemplate_default = (args) => {
|
|
|
160
161
|
// proxy.ts
|
|
161
162
|
import { sendAsyncRes as sendAsyncRes3 } from "@taqueria/node-sdk";
|
|
162
163
|
import { execa } from "execa";
|
|
163
|
-
var execCmd = (cmd, args) => {
|
|
164
|
+
var execCmd = (cmd, args, env) => {
|
|
164
165
|
var _a, _b;
|
|
165
166
|
const child = execa(cmd, args, {
|
|
166
167
|
shell: true,
|
|
167
168
|
reject: false,
|
|
168
|
-
env: { FORCE_COLOR: "true" }
|
|
169
|
+
env: { FORCE_COLOR: "true", TAQUERIA_ENV: env }
|
|
169
170
|
});
|
|
170
171
|
(_a = child.stdout) == null ? void 0 : _a.pipe(process.stdout);
|
|
171
172
|
(_b = child.stderr) == null ? void 0 : _b.pipe(process.stderr);
|
|
@@ -175,7 +176,7 @@ var proxy_default = (args) => {
|
|
|
175
176
|
const parsedArgs = toRequestArgs(args);
|
|
176
177
|
return ensureSelectedPartitionExists(parsedArgs, parsedArgs.init ? true : false).then((configAbsPath) => {
|
|
177
178
|
if (!parsedArgs.init) {
|
|
178
|
-
const retval = parsedArgs.testPattern ? execCmd("npx", ["jest", "-c", configAbsPath, "--testPathPattern", parsedArgs.testPattern]) : execCmd("npx", ["jest", "-c", configAbsPath]);
|
|
179
|
+
const retval = parsedArgs.testPattern ? execCmd("npx", ["jest", "-c", configAbsPath, "--testPathPattern", parsedArgs.testPattern], parsedArgs.env) : execCmd("npx", ["jest", "-c", configAbsPath], parsedArgs.env);
|
|
179
180
|
return retval.then((child) => {
|
|
180
181
|
if (child.exitCode === 0)
|
|
181
182
|
return;
|
|
@@ -246,6 +247,7 @@ Plugin.create((requestArgs) => ({
|
|
|
246
247
|
handler: contractTestTemplate_default
|
|
247
248
|
})
|
|
248
249
|
],
|
|
249
|
-
proxy: proxy_default
|
|
250
|
+
proxy: proxy_default,
|
|
251
|
+
postInstall: "bash -c 'npm install --save-dev ts-jest @types/jest'"
|
|
250
252
|
}), process.argv);
|
|
251
253
|
//# sourceMappingURL=index.js.map
|
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}), 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 { char2Bytes } from '@taquito/utils';\nimport { tas } from './types/type-aliases';\nimport { InMemorySigner, importKey } 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 config = require('../.taq/config.json')\n const Tezos = new TezosToolkit(config.sandbox.local.rpcUrl);\n\tconst key = config.sandbox.local.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[]) => {\n\tconst child = execa(cmd, args, {\n\t\tshell: true,\n\t\treject: false,\n\t\tenv: { FORCE_COLOR: 'true' },\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])\n\t\t\t\t\t: execCmd('npx', ['jest', '-c', configAbsPath]);\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,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,iBAAiB;AAAA,E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b,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;AACD,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 { 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\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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/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-jest",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.2",
|
|
4
4
|
"main": "index.cjs",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"source": "index.ts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"directory": "taqueria-plugin-jest"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@taqueria/node-sdk": "^0.50.
|
|
31
|
-
"@taqueria/plugin-contract-types": "^0.50.
|
|
30
|
+
"@taqueria/node-sdk": "^0.50.2",
|
|
31
|
+
"@taqueria/plugin-contract-types": "^0.50.2",
|
|
32
32
|
"@taquito/signer": "^19.1.0",
|
|
33
33
|
"@taquito/taquito": "^19.1.0",
|
|
34
34
|
"@taquito/utils": "^19.1.0",
|
|
@@ -36,9 +36,7 @@
|
|
|
36
36
|
"async-retry": "^1.3.3",
|
|
37
37
|
"bignumber.js": "^9.1.2",
|
|
38
38
|
"execa": "^8.0.1",
|
|
39
|
-
"fast-glob": "^3.3.2"
|
|
40
|
-
"jest-config": "^29.7.0",
|
|
41
|
-
"ts-jest": "^29.1.2"
|
|
39
|
+
"fast-glob": "^3.3.2"
|
|
42
40
|
},
|
|
43
41
|
"devDependencies": {
|
|
44
42
|
"@types/async-retry": "^1.4.8",
|
package/proxy.ts
CHANGED
|
@@ -3,11 +3,11 @@ import { RequestArgs } from '@taqueria/node-sdk';
|
|
|
3
3
|
import { execa } from 'execa';
|
|
4
4
|
import { CustomRequestArgs, ensureSelectedPartitionExists, toRequestArgs } from './common';
|
|
5
5
|
|
|
6
|
-
const execCmd = (cmd: string, args: string[]) => {
|
|
6
|
+
const execCmd = (cmd: string, args: string[], env: string) => {
|
|
7
7
|
const child = execa(cmd, args, {
|
|
8
8
|
shell: true,
|
|
9
9
|
reject: false,
|
|
10
|
-
env: { FORCE_COLOR: 'true' },
|
|
10
|
+
env: { FORCE_COLOR: 'true', TAQUERIA_ENV: env },
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
child.stdout?.pipe(process.stdout);
|
|
@@ -21,8 +21,8 @@ export default (args: RequestArgs.t) => {
|
|
|
21
21
|
.then(configAbsPath => {
|
|
22
22
|
if (!parsedArgs.init) {
|
|
23
23
|
const retval = parsedArgs.testPattern
|
|
24
|
-
? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', parsedArgs.testPattern])
|
|
25
|
-
: execCmd('npx', ['jest', '-c', configAbsPath]);
|
|
24
|
+
? execCmd('npx', ['jest', '-c', configAbsPath, '--testPathPattern', parsedArgs.testPattern], parsedArgs.env)
|
|
25
|
+
: execCmd('npx', ['jest', '-c', configAbsPath], parsedArgs.env);
|
|
26
26
|
return retval.then(child => {
|
|
27
27
|
if (child.exitCode === 0) return;
|
|
28
28
|
else process.exit(child.exitCode);
|