@taqueria/plugin-jest 0.24.2 → 0.25.3-alpha

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/common.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { noop, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
2
- import { LoadedConfig, RequestArgs, SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';
1
+ import { noop, RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
2
+ import { SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';
3
3
  import { mkdir, stat, writeFile } from 'fs/promises';
4
4
  import { defaults } from 'jest-config';
5
5
  import { join, relative } from 'path';
6
- import * as JestConfig from './config';
6
+ import JestConfig from './config';
7
7
 
8
8
  export type DefaultConfig = typeof defaults;
9
9
 
10
10
  export interface CustomRequestArgs extends RequestArgs.t {
11
- config: JestConfig.t;
11
+ config: JestConfig;
12
12
  partition?: string;
13
13
  init?: string;
14
14
  testPattern?: string;
@@ -16,15 +16,15 @@ export interface CustomRequestArgs extends RequestArgs.t {
16
16
 
17
17
  export const toRequestArgs = (args: RequestArgs.t): CustomRequestArgs => {
18
18
  const config = {
19
+ ...args.config,
19
20
  jest: {
20
21
  testsRootDir: 'tests',
21
22
  },
22
- ...args.config,
23
23
  };
24
24
 
25
25
  return {
26
26
  ...args,
27
- config: JestConfig.create(config),
27
+ config,
28
28
  };
29
29
  };
30
30
 
@@ -49,7 +49,7 @@ export const getRootConfigAbspath = (projectDir: SanitizedAbsPath.t) =>
49
49
  join(projectDir, '.taq', 'jest.config.js'),
50
50
  );
51
51
 
52
- export const getTestsRootDir = (config: JestConfig.t) => {
52
+ export const getTestsRootDir = (config: JestConfig) => {
53
53
  return config.jest.testsRootDir;
54
54
  };
55
55
 
@@ -69,14 +69,15 @@ export const getPartitionAbspath = (partitionDir: string) => SanitizedAbsPath.cr
69
69
  export const getPartitionConfigAbspath = (partitionDir: string) =>
70
70
  SanitizedAbsPath.create(join(partitionDir, 'jest.config.js'));
71
71
 
72
- export const initPartition = (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) =>
73
- writeFile(
72
+ export const initPartition = (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) => {
73
+ return writeFile(
74
74
  getPartitionConfigAbspath(partitionDir),
75
75
  toPartitionCfg(
76
- SanitizedPath.create(relative(partitionDir, partitionDir)),
76
+ SanitizedPath.create('./'),
77
77
  SanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),
78
78
  ),
79
79
  );
80
+ };
80
81
 
81
82
  export const ensurePartitionExists = async (
82
83
  partitionDir: SanitizedAbsPath.t,
@@ -103,13 +104,13 @@ export const ensureSelectedPartitionExists = (args: CustomRequestArgs, forceCrea
103
104
  args.partition
104
105
  ? ensurePartitionExists(
105
106
  SanitizedAbsPath.create(join(args.projectDir, args.partition)),
106
- args.projectDir,
107
+ SanitizedPath.create(args.projectDir),
107
108
  forceCreate,
108
109
  )
109
110
  : ensurePartitionExists(
110
111
  SanitizedAbsPath.create(
111
112
  join(args.projectDir, getTestsRootDir(args.config)),
112
113
  ),
113
- args.projectDir,
114
+ SanitizedPath.create(args.projectDir),
114
115
  forceCreate,
115
116
  );
package/config.ts CHANGED
@@ -1,50 +1,9 @@
1
1
  import { LoadedConfig } from '@taqueria/node-sdk';
2
- import { z } from 'zod';
3
2
 
4
- const jestType: unique symbol = Symbol('jestConfig');
5
-
6
- const rawSchema = LoadedConfig.rawSchema.extend({
7
- jest: z.preprocess(
8
- input => {
9
- const overrides = typeof input === 'object'
10
- ? input
11
- : {};
12
-
13
- return {
14
- 'testsRootDir': 'tests',
15
- ...overrides,
16
- };
17
- },
18
- z.object({
19
- 'testsRootDir': z.preprocess(
20
- val => val ?? 'tests',
21
- z.string().min(1).describe('testsRootDir'),
22
- ),
23
- }),
24
- ),
25
- });
26
-
27
- const internalSchema = Object.assign({}, rawSchema);
28
-
29
- type RawInput = z.infer<typeof rawSchema>;
30
-
31
- type Input = z.infer<typeof internalSchema>;
32
-
33
- export interface JestRawConfig extends LoadedConfig.t {
34
- [jestType]: void;
35
- }
36
-
37
- export type JestConfig = Input & JestRawConfig;
38
-
39
- export type t = JestConfig;
40
-
41
- export const schema = internalSchema.transform(val => val as JestConfig);
42
-
43
- export const create = (input: RawInput | unknown) => {
44
- try {
45
- const retval = schema.parse(input);
46
- return retval;
47
- } catch {
48
- throw `The .taq/config.json file is invalid.`;
49
- }
3
+ export type JestConfig = LoadedConfig.t & {
4
+ jest: {
5
+ testsRootDir: string;
6
+ };
50
7
  };
8
+
9
+ export default JestConfig;
@@ -1,5 +1,5 @@
1
1
  // import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';
2
- import { sendAsyncRes } from '@taqueria/node-sdk';
2
+ import { RequestArgs, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
3
3
  import { generateContractTypesProcessContractFiles } from '@taqueria/plugin-contract-types/src/cli-process.js';
4
4
  import {
5
5
  createTestingCodeGenerator,
@@ -12,12 +12,13 @@ import { CustomRequestArgs, ensureSelectedPartitionExists, getPartitionAbspath,
12
12
  type Generator = ReturnType<typeof createTestingCodeGenerator>;
13
13
 
14
14
  interface Opts extends CustomRequestArgs {
15
- readonly michelsonArtifact: string;
15
+ readonly michelsonArtifact?: string;
16
16
  readonly partition?: string;
17
17
  readonly name?: string;
18
18
  }
19
19
 
20
- const getMichelsonAbspath = (parsedArgs: Opts) => join(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);
20
+ const getMichelsonAbspath = (parsedArgs: Opts) =>
21
+ join(parsedArgs.config.artifactsDir ?? 'artifacts', parsedArgs.michelsonArtifact!);
21
22
 
22
23
  const ensureMichelsonExists = (parsedArgs: Opts) => {
23
24
  const abspath = getMichelsonAbspath(parsedArgs);
@@ -35,7 +36,7 @@ const getTypesOutputAbspath = (parsedArgs: Opts) => join(getPartition(parsedArgs
35
36
 
36
37
  const generateContractTypes = (parsedArgs: Opts) =>
37
38
  generateContractTypesProcessContractFiles({
38
- inputTzContractDirectory: parsedArgs.config.artifactsDir,
39
+ inputTzContractDirectory: parsedArgs.config.artifactsDir ?? 'artifacts',
39
40
  inputFiles: [getMichelsonAbspath(parsedArgs)],
40
41
  outputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),
41
42
  format: 'tz',
@@ -45,7 +46,7 @@ const generateContractTypes = (parsedArgs: Opts) =>
45
46
  const getContractName = (parsedArgs: Opts) =>
46
47
  parsedArgs.name
47
48
  ? parsedArgs.name.trim().replace(/\.ts$/, '')
48
- : basename(parsedArgs.michelsonArtifact, '.tz');
49
+ : basename(parsedArgs.michelsonArtifact!, '.tz');
49
50
 
50
51
  const generateTestSuite = (parsedArgs: Opts) => {
51
52
  const michelsonAbspath = getMichelsonAbspath(parsedArgs);
@@ -110,11 +111,14 @@ ${
110
111
  `;
111
112
  };
112
113
 
113
- export default (parsedArgs: Opts) => {
114
- return ensureMichelsonExists(parsedArgs)
115
- .then(ensureSelectedPartitionExists)
116
- .then(() => parsedArgs)
117
- .then(generateContractTypes)
118
- .then(generateTestSuite)
119
- .then(outFile => sendAsyncRes(`Test suite generated: ${outFile}`));
114
+ export default (args: RequestArgs.t) => {
115
+ const parsedArgs = args as Opts;
116
+ parsedArgs.michelsonArtifact
117
+ ? ensureMichelsonExists(parsedArgs)
118
+ .then(ensureSelectedPartitionExists)
119
+ .then(() => parsedArgs)
120
+ .then(generateContractTypes)
121
+ .then(generateTestSuite)
122
+ .then((outFile: string) => sendAsyncRes(`Test suite generated: ${outFile}`))
123
+ : sendAsyncErr(`No michelson artifact provided`);
120
124
  };
package/index.cjs CHANGED
@@ -1,58 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  // index.ts
4
- var import_node_sdk5 = require("@taqueria/node-sdk");
4
+ var import_node_sdk4 = require("@taqueria/node-sdk");
5
5
 
6
6
  // common.ts
7
- var import_node_sdk2 = require("@taqueria/node-sdk");
7
+ var import_node_sdk = require("@taqueria/node-sdk");
8
8
  var import_types = require("@taqueria/node-sdk/types");
9
9
  var import_promises = require("fs/promises");
10
10
  var import_jest_config = require("jest-config");
11
11
  var import_path = require("path");
12
-
13
- // config.ts
14
- var import_node_sdk = require("@taqueria/node-sdk");
15
- var import_zod = require("zod");
16
- var jestType = Symbol("jestConfig");
17
- var rawSchema = import_node_sdk.LoadedConfig.rawSchema.extend({
18
- jest: import_zod.z.preprocess(
19
- (input) => {
20
- const overrides = typeof input === "object" ? input : {};
21
- return {
22
- "testsRootDir": "tests",
23
- ...overrides
24
- };
25
- },
26
- import_zod.z.object({
27
- "testsRootDir": import_zod.z.preprocess(
28
- (val) => val ?? "tests",
29
- import_zod.z.string().min(1).describe("testsRootDir")
30
- )
31
- })
32
- )
33
- });
34
- var internalSchema = Object.assign({}, rawSchema);
35
- var schema = internalSchema.transform((val) => val);
36
- var create = (input) => {
37
- try {
38
- const retval = schema.parse(input);
39
- return retval;
40
- } catch {
41
- throw `The .taq/config.json file is invalid.`;
42
- }
43
- };
44
-
45
- // common.ts
46
12
  var toRequestArgs = (args) => {
47
13
  const config = {
14
+ ...args.config,
48
15
  jest: {
49
16
  testsRootDir: "tests"
50
- },
51
- ...args.config
17
+ }
52
18
  };
53
19
  return {
54
20
  ...args,
55
- config: create(config)
21
+ config
56
22
  };
57
23
  };
58
24
  var getDefaultConfig = (defaultConfig) => {
@@ -83,37 +49,39 @@ module.exports = {
83
49
  `;
84
50
  var getPartitionAbspath = (partitionDir) => import_types.SanitizedAbsPath.create(partitionDir);
85
51
  var getPartitionConfigAbspath = (partitionDir) => import_types.SanitizedAbsPath.create((0, import_path.join)(partitionDir, "jest.config.js"));
86
- var initPartition = (partitionDir, projectDir) => (0, import_promises.writeFile)(
87
- getPartitionConfigAbspath(partitionDir),
88
- toPartitionCfg(
89
- import_types.SanitizedPath.create((0, import_path.relative)(partitionDir, partitionDir)),
90
- import_types.SanitizedPath.create((0, import_path.relative)(partitionDir, getRootConfigAbspath(projectDir)))
91
- )
92
- );
52
+ var initPartition = (partitionDir, projectDir) => {
53
+ return (0, import_promises.writeFile)(
54
+ getPartitionConfigAbspath(partitionDir),
55
+ toPartitionCfg(
56
+ import_types.SanitizedPath.create("./"),
57
+ import_types.SanitizedPath.create((0, import_path.relative)(partitionDir, getRootConfigAbspath(projectDir)))
58
+ )
59
+ );
60
+ };
93
61
  var ensurePartitionExists = async (partitionDir, projectDir, forceCreate = false) => ensureRootConfigExists(projectDir).then((_) => (0, import_promises.stat)(partitionDir)).then(
94
- (stats) => stats.isFile() ? (0, import_node_sdk2.sendAsyncErr)(`${partitionDir} is an invalid partition directory`) : stats
62
+ (stats) => stats.isFile() ? (0, import_node_sdk.sendAsyncErr)(`${partitionDir} is an invalid partition directory`) : stats
95
63
  ).catch((_) => (0, import_promises.mkdir)(partitionDir, { recursive: true })).then((_) => getPartitionConfigAbspath(partitionDir)).then(
96
64
  (partitionCfgAbsPath) => (0, import_promises.stat)(partitionCfgAbsPath).then((_) => forceCreate ? initPartition(partitionDir, projectDir) : void 0).catch((_) => initPartition(partitionDir, projectDir))
97
65
  ).then((_) => getPartitionConfigAbspath(partitionDir));
98
66
  var ensureSelectedPartitionExists = (args, forceCreate = false) => args.partition ? ensurePartitionExists(
99
67
  import_types.SanitizedAbsPath.create((0, import_path.join)(args.projectDir, args.partition)),
100
- args.projectDir,
68
+ import_types.SanitizedPath.create(args.projectDir),
101
69
  forceCreate
102
70
  ) : ensurePartitionExists(
103
71
  import_types.SanitizedAbsPath.create(
104
72
  (0, import_path.join)(args.projectDir, getTestsRootDir(args.config))
105
73
  ),
106
- args.projectDir,
74
+ import_types.SanitizedPath.create(args.projectDir),
107
75
  forceCreate
108
76
  );
109
77
 
110
78
  // contractTestTemplate.ts
111
- var import_node_sdk3 = require("@taqueria/node-sdk");
79
+ var import_node_sdk2 = require("@taqueria/node-sdk");
112
80
  var import_cli_process = require("@taqueria/plugin-contract-types/src/cli-process.js");
113
81
  var import_testing_code_generator = require("@taqueria/plugin-contract-types/src/generator/testing-code-generator.js");
114
82
  var import_promises2 = require("fs/promises");
115
83
  var import_path2 = require("path");
116
- var getMichelsonAbspath = (parsedArgs) => (0, import_path2.join)(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);
84
+ var getMichelsonAbspath = (parsedArgs) => (0, import_path2.join)(parsedArgs.config.artifactsDir ?? "artifacts", parsedArgs.michelsonArtifact);
117
85
  var ensureMichelsonExists = (parsedArgs) => {
118
86
  const abspath = getMichelsonAbspath(parsedArgs);
119
87
  return (0, import_promises2.stat)(abspath).then(() => parsedArgs).catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run "taq compile"?`));
@@ -124,7 +92,7 @@ var getPartition = (parsedArgs) => {
124
92
  };
125
93
  var getTypesOutputAbspath = (parsedArgs) => (0, import_path2.join)(getPartition(parsedArgs), "types");
126
94
  var generateContractTypes = (parsedArgs) => (0, import_cli_process.generateContractTypesProcessContractFiles)({
127
- inputTzContractDirectory: parsedArgs.config.artifactsDir,
95
+ inputTzContractDirectory: parsedArgs.config.artifactsDir ?? "artifacts",
128
96
  inputFiles: [getMichelsonAbspath(parsedArgs)],
129
97
  outputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),
130
98
  format: "tz",
@@ -183,12 +151,13 @@ ${methodCalls.map((x) => `
183
151
  `).join("")}});
184
152
  `;
185
153
  };
186
- var contractTestTemplate_default = (parsedArgs) => {
187
- return ensureMichelsonExists(parsedArgs).then(ensureSelectedPartitionExists).then(() => parsedArgs).then(generateContractTypes).then(generateTestSuite).then((outFile) => (0, import_node_sdk3.sendAsyncRes)(`Test suite generated: ${outFile}`));
154
+ var contractTestTemplate_default = (args) => {
155
+ const parsedArgs = args;
156
+ parsedArgs.michelsonArtifact ? ensureMichelsonExists(parsedArgs).then(ensureSelectedPartitionExists).then(() => parsedArgs).then(generateContractTypes).then(generateTestSuite).then((outFile) => (0, import_node_sdk2.sendAsyncRes)(`Test suite generated: ${outFile}`)) : (0, import_node_sdk2.sendAsyncErr)(`No michelson artifact provided`);
188
157
  };
189
158
 
190
159
  // proxy.ts
191
- var import_node_sdk4 = require("@taqueria/node-sdk");
160
+ var import_node_sdk3 = require("@taqueria/node-sdk");
192
161
  var import_execa = require("execa");
193
162
  var execCmd = (cmd, args) => {
194
163
  var _a, _b;
@@ -213,24 +182,24 @@ var proxy_default = async (args) => {
213
182
  process.exit(child.exitCode);
214
183
  });
215
184
  }
216
- return (0, import_node_sdk4.sendAsyncRes)("Initialized successfully.");
185
+ return (0, import_node_sdk3.sendAsyncRes)("Initialized successfully.");
217
186
  });
218
187
  };
219
188
 
220
189
  // index.ts
221
- import_node_sdk5.Plugin.create((requestArgs) => ({
190
+ import_node_sdk4.Plugin.create((requestArgs) => ({
222
191
  schema: "0.1",
223
192
  version: "0.4.0",
224
193
  alias: "jest",
225
194
  tasks: [
226
- import_node_sdk5.Task.create({
195
+ import_node_sdk4.Task.create({
227
196
  task: "test",
228
197
  command: "test [partition]",
229
198
  description: "Setup a directory as a partition to run Jest tests",
230
199
  aliases: ["jest"],
231
200
  handler: "proxy",
232
201
  positionals: [
233
- import_node_sdk5.PositionalArg.create({
202
+ import_node_sdk4.PositionalArg.create({
234
203
  placeholder: "partition",
235
204
  description: "Name of the partition for these tests",
236
205
  defaultValue: "tests",
@@ -238,13 +207,13 @@ import_node_sdk5.Plugin.create((requestArgs) => ({
238
207
  })
239
208
  ],
240
209
  options: [
241
- import_node_sdk5.Option.create({
210
+ import_node_sdk4.Option.create({
242
211
  flag: "init",
243
212
  shortFlag: "i",
244
213
  description: "Initializes the partition for Jest",
245
214
  boolean: true
246
215
  }),
247
- import_node_sdk5.Option.create({
216
+ import_node_sdk4.Option.create({
248
217
  flag: "testPattern",
249
218
  shortFlag: "t",
250
219
  description: "Run test files that match the provided pattern"
@@ -253,11 +222,11 @@ import_node_sdk5.Plugin.create((requestArgs) => ({
253
222
  })
254
223
  ],
255
224
  templates: [
256
- import_node_sdk5.Template.create({
225
+ import_node_sdk4.Template.create({
257
226
  template: "contract-test",
258
227
  command: "contract-test <michelsonArtifact>",
259
228
  positionals: [
260
- import_node_sdk5.PositionalArg.create({
229
+ import_node_sdk4.PositionalArg.create({
261
230
  placeholder: "michelsonArtifact",
262
231
  description: "Name of the michelson contract (artifact) to generate tests for",
263
232
  required: true,
@@ -265,7 +234,7 @@ import_node_sdk5.Plugin.create((requestArgs) => ({
265
234
  })
266
235
  ],
267
236
  options: [
268
- import_node_sdk5.Option.create({
237
+ import_node_sdk4.Option.create({
269
238
  flag: "partition",
270
239
  description: "Partition to place generated test suite",
271
240
  type: "string",
package/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts","common.ts","config.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, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { LoadedConfig, RequestArgs, 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 * as JestConfig from './config';\n\nexport type DefaultConfig = typeof defaults;\n\nexport interface CustomRequestArgs extends RequestArgs.t {\n\tconfig: JestConfig.t;\n\tpartition?: string;\n\tinit?: string;\n\ttestPattern?: string;\n}\n\nexport const toRequestArgs = (args: RequestArgs.t): CustomRequestArgs => {\n\tconst config = {\n\t\tjest: {\n\t\t\ttestsRootDir: 'tests',\n\t\t},\n\t\t...args.config,\n\t};\n\n\treturn {\n\t\t...args,\n\t\tconfig: JestConfig.create(config),\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.t) => {\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\twriteFile(\n\t\tgetPartitionConfigAbspath(partitionDir),\n\t\ttoPartitionCfg(\n\t\t\tSanitizedPath.create(relative(partitionDir, partitionDir)),\n\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t),\n\t);\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\targs.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\targs.projectDir,\n\t\t\tforceCreate,\n\t\t);\n","import { LoadedConfig } from '@taqueria/node-sdk';\nimport { z } from 'zod';\n\nconst jestType: unique symbol = Symbol('jestConfig');\n\nconst rawSchema = LoadedConfig.rawSchema.extend({\n\tjest: z.preprocess(\n\t\tinput => {\n\t\t\tconst overrides = typeof input === 'object'\n\t\t\t\t? input\n\t\t\t\t: {};\n\n\t\t\treturn {\n\t\t\t\t'testsRootDir': 'tests',\n\t\t\t\t...overrides,\n\t\t\t};\n\t\t},\n\t\tz.object({\n\t\t\t'testsRootDir': z.preprocess(\n\t\t\t\tval => val ?? 'tests',\n\t\t\t\tz.string().min(1).describe('testsRootDir'),\n\t\t\t),\n\t\t}),\n\t),\n});\n\nconst internalSchema = Object.assign({}, rawSchema);\n\ntype RawInput = z.infer<typeof rawSchema>;\n\ntype Input = z.infer<typeof internalSchema>;\n\nexport interface JestRawConfig extends LoadedConfig.t {\n\t[jestType]: void;\n}\n\nexport type JestConfig = Input & JestRawConfig;\n\nexport type t = JestConfig;\n\nexport const schema = internalSchema.transform(val => val as JestConfig);\n\nexport const create = (input: RawInput | unknown) => {\n\ttry {\n\t\tconst retval = schema.parse(input);\n\t\treturn retval;\n\t} catch {\n\t\tthrow `The .taq/config.json file is invalid.`;\n\t}\n};\n","// import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';\nimport { 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) => join(parsedArgs.config.artifactsDir, 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,\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) =>\n\t(generator: Generator) => {\n\t\tconst methodCalls = generator.methods.map(m => ({\n\t\t\tname: m.name,\n\t\t\tmethodCall: generator.generateMethodCall({\n\t\t\t\tmethodName: m.name,\n\t\t\t\tformatting: {\n\t\t\t\t\tindent: 2,\n\t\t\t\t},\n\t\t\t}),\n\t\t\tstorageAccess: generator.generateStorageAccess({ storagePath: '' }),\n\t\t}));\n\t\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\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\t}});\n`;\n\t};\n\nexport default (parsedArgs: Opts) => {\n\treturn ensureMichelsonExists(parsedArgs)\n\t\t.then(ensureSelectedPartitionExists)\n\t\t.then(() => parsedArgs)\n\t\t.then(generateContractTypes)\n\t\t.then(generateTestSuite)\n\t\t.then(outFile => sendAsyncRes(`Test suite generated: ${outFile}`));\n};\n","import { sendAsyncRes } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk/types';\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 async (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,I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AAS;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_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}), 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) =>\n\t(generator: Generator) => {\n\t\tconst methodCalls = generator.methods.map(m => ({\n\t\t\tname: m.name,\n\t\t\tmethodCall: generator.generateMethodCall({\n\t\t\t\tmethodName: m.name,\n\t\t\t\tformatting: {\n\t\t\t\t\tindent: 2,\n\t\t\t\t},\n\t\t\t}),\n\t\t\tstorageAccess: generator.generateStorageAccess({ storagePath: '' }),\n\t\t}));\n\t\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\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\t}});\n`;\n\t};\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: sendAsyncErr(`No michelson artifact provided`);\n};\n","import { sendAsyncRes } 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 async (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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H5BA,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"]}
package/index.js CHANGED
@@ -7,50 +7,16 @@ import { SanitizedAbsPath, SanitizedPath } from "@taqueria/node-sdk/types";
7
7
  import { mkdir, stat, writeFile } from "fs/promises";
8
8
  import { defaults } from "jest-config";
9
9
  import { join, relative } from "path";
10
-
11
- // config.ts
12
- import { LoadedConfig } from "@taqueria/node-sdk";
13
- import { z } from "zod";
14
- var jestType = Symbol("jestConfig");
15
- var rawSchema = LoadedConfig.rawSchema.extend({
16
- jest: z.preprocess(
17
- (input) => {
18
- const overrides = typeof input === "object" ? input : {};
19
- return {
20
- "testsRootDir": "tests",
21
- ...overrides
22
- };
23
- },
24
- z.object({
25
- "testsRootDir": z.preprocess(
26
- (val) => val ?? "tests",
27
- z.string().min(1).describe("testsRootDir")
28
- )
29
- })
30
- )
31
- });
32
- var internalSchema = Object.assign({}, rawSchema);
33
- var schema = internalSchema.transform((val) => val);
34
- var create = (input) => {
35
- try {
36
- const retval = schema.parse(input);
37
- return retval;
38
- } catch {
39
- throw `The .taq/config.json file is invalid.`;
40
- }
41
- };
42
-
43
- // common.ts
44
10
  var toRequestArgs = (args) => {
45
11
  const config = {
12
+ ...args.config,
46
13
  jest: {
47
14
  testsRootDir: "tests"
48
- },
49
- ...args.config
15
+ }
50
16
  };
51
17
  return {
52
18
  ...args,
53
- config: create(config)
19
+ config
54
20
  };
55
21
  };
56
22
  var getDefaultConfig = (defaultConfig) => {
@@ -81,13 +47,15 @@ module.exports = {
81
47
  `;
82
48
  var getPartitionAbspath = (partitionDir) => SanitizedAbsPath.create(partitionDir);
83
49
  var getPartitionConfigAbspath = (partitionDir) => SanitizedAbsPath.create(join(partitionDir, "jest.config.js"));
84
- var initPartition = (partitionDir, projectDir) => writeFile(
85
- getPartitionConfigAbspath(partitionDir),
86
- toPartitionCfg(
87
- SanitizedPath.create(relative(partitionDir, partitionDir)),
88
- SanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir)))
89
- )
90
- );
50
+ var initPartition = (partitionDir, projectDir) => {
51
+ return writeFile(
52
+ getPartitionConfigAbspath(partitionDir),
53
+ toPartitionCfg(
54
+ SanitizedPath.create("./"),
55
+ SanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir)))
56
+ )
57
+ );
58
+ };
91
59
  var ensurePartitionExists = async (partitionDir, projectDir, forceCreate = false) => ensureRootConfigExists(projectDir).then((_) => stat(partitionDir)).then(
92
60
  (stats) => stats.isFile() ? sendAsyncErr(`${partitionDir} is an invalid partition directory`) : stats
93
61
  ).catch((_) => mkdir(partitionDir, { recursive: true })).then((_) => getPartitionConfigAbspath(partitionDir)).then(
@@ -95,18 +63,18 @@ var ensurePartitionExists = async (partitionDir, projectDir, forceCreate = false
95
63
  ).then((_) => getPartitionConfigAbspath(partitionDir));
96
64
  var ensureSelectedPartitionExists = (args, forceCreate = false) => args.partition ? ensurePartitionExists(
97
65
  SanitizedAbsPath.create(join(args.projectDir, args.partition)),
98
- args.projectDir,
66
+ SanitizedPath.create(args.projectDir),
99
67
  forceCreate
100
68
  ) : ensurePartitionExists(
101
69
  SanitizedAbsPath.create(
102
70
  join(args.projectDir, getTestsRootDir(args.config))
103
71
  ),
104
- args.projectDir,
72
+ SanitizedPath.create(args.projectDir),
105
73
  forceCreate
106
74
  );
107
75
 
108
76
  // contractTestTemplate.ts
109
- import { sendAsyncRes as sendAsyncRes2 } from "@taqueria/node-sdk";
77
+ import { sendAsyncErr as sendAsyncErr2, sendAsyncRes as sendAsyncRes2 } from "@taqueria/node-sdk";
110
78
  import { generateContractTypesProcessContractFiles } from "@taqueria/plugin-contract-types/src/cli-process.js";
111
79
  import {
112
80
  createTestingCodeGenerator,
@@ -114,7 +82,7 @@ import {
114
82
  } from "@taqueria/plugin-contract-types/src/generator/testing-code-generator.js";
115
83
  import { readFile, stat as stat2, writeFile as writeFile2 } from "fs/promises";
116
84
  import { basename, join as join2 } from "path";
117
- var getMichelsonAbspath = (parsedArgs) => join2(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);
85
+ var getMichelsonAbspath = (parsedArgs) => join2(parsedArgs.config.artifactsDir ?? "artifacts", parsedArgs.michelsonArtifact);
118
86
  var ensureMichelsonExists = (parsedArgs) => {
119
87
  const abspath = getMichelsonAbspath(parsedArgs);
120
88
  return stat2(abspath).then(() => parsedArgs).catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run "taq compile"?`));
@@ -125,7 +93,7 @@ var getPartition = (parsedArgs) => {
125
93
  };
126
94
  var getTypesOutputAbspath = (parsedArgs) => join2(getPartition(parsedArgs), "types");
127
95
  var generateContractTypes = (parsedArgs) => generateContractTypesProcessContractFiles({
128
- inputTzContractDirectory: parsedArgs.config.artifactsDir,
96
+ inputTzContractDirectory: parsedArgs.config.artifactsDir ?? "artifacts",
129
97
  inputFiles: [getMichelsonAbspath(parsedArgs)],
130
98
  outputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),
131
99
  format: "tz",
@@ -184,8 +152,9 @@ ${methodCalls.map((x) => `
184
152
  `).join("")}});
185
153
  `;
186
154
  };
187
- var contractTestTemplate_default = (parsedArgs) => {
188
- return ensureMichelsonExists(parsedArgs).then(ensureSelectedPartitionExists).then(() => parsedArgs).then(generateContractTypes).then(generateTestSuite).then((outFile) => sendAsyncRes2(`Test suite generated: ${outFile}`));
155
+ var contractTestTemplate_default = (args) => {
156
+ const parsedArgs = args;
157
+ parsedArgs.michelsonArtifact ? ensureMichelsonExists(parsedArgs).then(ensureSelectedPartitionExists).then(() => parsedArgs).then(generateContractTypes).then(generateTestSuite).then((outFile) => sendAsyncRes2(`Test suite generated: ${outFile}`)) : sendAsyncErr2(`No michelson artifact provided`);
189
158
  };
190
159
 
191
160
  // proxy.ts
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts","common.ts","config.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, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';\nimport { LoadedConfig, RequestArgs, 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 * as JestConfig from './config';\n\nexport type DefaultConfig = typeof defaults;\n\nexport interface CustomRequestArgs extends RequestArgs.t {\n\tconfig: JestConfig.t;\n\tpartition?: string;\n\tinit?: string;\n\ttestPattern?: string;\n}\n\nexport const toRequestArgs = (args: RequestArgs.t): CustomRequestArgs => {\n\tconst config = {\n\t\tjest: {\n\t\t\ttestsRootDir: 'tests',\n\t\t},\n\t\t...args.config,\n\t};\n\n\treturn {\n\t\t...args,\n\t\tconfig: JestConfig.create(config),\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.t) => {\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\twriteFile(\n\t\tgetPartitionConfigAbspath(partitionDir),\n\t\ttoPartitionCfg(\n\t\t\tSanitizedPath.create(relative(partitionDir, partitionDir)),\n\t\t\tSanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),\n\t\t),\n\t);\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\targs.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\targs.projectDir,\n\t\t\tforceCreate,\n\t\t);\n","import { LoadedConfig } from '@taqueria/node-sdk';\nimport { z } from 'zod';\n\nconst jestType: unique symbol = Symbol('jestConfig');\n\nconst rawSchema = LoadedConfig.rawSchema.extend({\n\tjest: z.preprocess(\n\t\tinput => {\n\t\t\tconst overrides = typeof input === 'object'\n\t\t\t\t? input\n\t\t\t\t: {};\n\n\t\t\treturn {\n\t\t\t\t'testsRootDir': 'tests',\n\t\t\t\t...overrides,\n\t\t\t};\n\t\t},\n\t\tz.object({\n\t\t\t'testsRootDir': z.preprocess(\n\t\t\t\tval => val ?? 'tests',\n\t\t\t\tz.string().min(1).describe('testsRootDir'),\n\t\t\t),\n\t\t}),\n\t),\n});\n\nconst internalSchema = Object.assign({}, rawSchema);\n\ntype RawInput = z.infer<typeof rawSchema>;\n\ntype Input = z.infer<typeof internalSchema>;\n\nexport interface JestRawConfig extends LoadedConfig.t {\n\t[jestType]: void;\n}\n\nexport type JestConfig = Input & JestRawConfig;\n\nexport type t = JestConfig;\n\nexport const schema = internalSchema.transform(val => val as JestConfig);\n\nexport const create = (input: RawInput | unknown) => {\n\ttry {\n\t\tconst retval = schema.parse(input);\n\t\treturn retval;\n\t} catch {\n\t\tthrow `The .taq/config.json file is invalid.`;\n\t}\n};\n","// import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';\nimport { 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) => join(parsedArgs.config.artifactsDir, 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,\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) =>\n\t(generator: Generator) => {\n\t\tconst methodCalls = generator.methods.map(m => ({\n\t\t\tname: m.name,\n\t\t\tmethodCall: generator.generateMethodCall({\n\t\t\t\tmethodName: m.name,\n\t\t\t\tformatting: {\n\t\t\t\t\tindent: 2,\n\t\t\t\t},\n\t\t\t}),\n\t\t\tstorageAccess: generator.generateStorageAccess({ storagePath: '' }),\n\t\t}));\n\t\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\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\t}});\n`;\n\t};\n\nexport default (parsedArgs: Opts) => {\n\treturn ensureMichelsonExists(parsedArgs)\n\t\t.then(ensureSelectedPartitionExists)\n\t\t.then(() => parsedArgs)\n\t\t.then(generateContractTypes)\n\t\t.then(generateTestSuite)\n\t\t.then(outFile => sendAsyncRes(`Test suite generated: ${outFile}`));\n};\n","import { sendAsyncRes } from '@taqueria/node-sdk';\nimport { RequestArgs } from '@taqueria/node-sdk/types';\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 async (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,SAAe,oBAAkC;AACjD,SAAoC,kBAAkB,qBAAqB;AAC3E,SAAS,OAAO,MAAM,iBAAiB;AACvC,SAAS,gBAAgB;AACzB,SAAS,MAAM,gBAAgB;;;ACJ/B,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,IAAM,WAA0B,OAAO,YAAY;AAEnD,IAAM,YAAY,aAAa,UAAU,OAAO;AAAA,EAC/C,MAAM,EAAE;AAAA,IACP,WAAS;AACR,YAAM,YAAY,OAAO,UAAU,WAChC,QACA,CAAC;AAEJ,aAAO;AAAA,QACN,gBAAgB;AAAA,QAChB,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,IACA,EAAE,OAAO;AAAA,MACR,gBAAgB,EAAE;AAAA,QACjB,SAAO,OAAO;AAAA,QACd,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,cAAc;AAAA,MAC1C;AAAA,IACD,CAAC;AAAA,EACF;AACD,CAAC;AAED,IAAM,iBAAiB,OAAO,OAAO,CAAC,GAAG,SAAS;AAc3C,IAAM,SAAS,eAA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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":["sendAsyncRes","stat","writeFile","join","join","stat","writeFile","sendAsyncRes","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}), 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) =>\n\t(generator: Generator) => {\n\t\tconst methodCalls = generator.methods.map(m => ({\n\t\t\tname: m.name,\n\t\t\tmethodCall: generator.generateMethodCall({\n\t\t\t\tmethodName: m.name,\n\t\t\t\tformatting: {\n\t\t\t\t\tindent: 2,\n\t\t\t\t},\n\t\t\t}),\n\t\t\tstorageAccess: generator.generateStorageAccess({ storagePath: '' }),\n\t\t}));\n\t\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\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\t}});\n`;\n\t};\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: sendAsyncErr(`No michelson artifact provided`);\n};\n","import { sendAsyncRes } 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 async (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;AAAA;AAGnD;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,EAChB,KAAK,YAAY,QAAQ,gBAAgB;AAC1C;AAEM,IAAM,kBAAkB,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,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/plugin-jest",
3
- "version": "0.24.2",
3
+ "version": "0.25.3-alpha",
4
4
  "main": "index.cjs",
5
5
  "module": "index.js",
6
6
  "source": "index.ts",
@@ -27,7 +27,7 @@
27
27
  "directory": "taqueria-plugin-jest"
28
28
  },
29
29
  "dependencies": {
30
- "@taqueria/node-sdk": "^0.24.2",
30
+ "@taqueria/node-sdk": "^0.25.3-alpha",
31
31
  "@taqueria/plugin-contract-types": "^0.14.4",
32
32
  "@taquito/signer": "^13.0.1",
33
33
  "@taquito/taquito": "^13.0.1",
package/proxy.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { sendAsyncRes } from '@taqueria/node-sdk';
2
- import { RequestArgs } from '@taqueria/node-sdk/types';
2
+ import { RequestArgs } from '@taqueria/node-sdk';
3
3
  import { execa } from 'execa';
4
4
  import { CustomRequestArgs, ensureSelectedPartitionExists, toRequestArgs } from './common';
5
5
 
package/tsconfig.json CHANGED
@@ -12,7 +12,9 @@
12
12
 
13
13
  /* Language and Environment */
14
14
  "target": "ES2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
15
+ "lib": [
16
+ "ES2021.String"
17
+ ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
18
  // "jsx": "preserve", /* Specify what JSX code is generated. */
17
19
  // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
20
  // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
@@ -77,7 +79,7 @@
77
79
  "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
78
80
 
79
81
  /* Type Checking */
80
- "strict": true /* Enable all strict type-checking options. */
82
+ "strict": true, /* Enable all strict type-checking options. */
81
83
  // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
82
84
  // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
83
85
  // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
@@ -99,6 +101,6 @@
99
101
 
100
102
  /* Completeness */
101
103
  // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
102
- // "skipLibCheck": true /* Skip type checking all .d.ts files. */
104
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
103
105
  }
104
106
  }