@taqueria/plugin-jest 0.25.4-alpha → 0.25.11-rc
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 +12 -13
- package/config.ts +47 -6
- package/contractTestTemplate.ts +12 -16
- package/index.cjs +64 -33
- package/index.cjs.map +1 -1
- package/index.js +51 -20
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/proxy.ts +1 -1
- package/tsconfig.json +3 -5
package/common.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { noop,
|
|
2
|
-
import { SanitizedAbsPath, SanitizedPath } from '@taqueria/node-sdk/types';
|
|
1
|
+
import { noop, sendAsyncErr, sendAsyncRes } from '@taqueria/node-sdk';
|
|
2
|
+
import { LoadedConfig, RequestArgs, 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 JestConfig from './config';
|
|
6
|
+
import * as 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;
|
|
11
|
+
config: JestConfig.t;
|
|
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,
|
|
20
19
|
jest: {
|
|
21
20
|
testsRootDir: 'tests',
|
|
22
21
|
},
|
|
22
|
+
...args.config,
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
return {
|
|
26
26
|
...args,
|
|
27
|
-
config,
|
|
27
|
+
config: JestConfig.create(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) => {
|
|
52
|
+
export const getTestsRootDir = (config: JestConfig.t) => {
|
|
53
53
|
return config.jest.testsRootDir;
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -69,15 +69,14 @@ 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
|
-
|
|
72
|
+
export const initPartition = (partitionDir: SanitizedAbsPath.t, projectDir: SanitizedAbsPath.t) =>
|
|
73
|
+
writeFile(
|
|
74
74
|
getPartitionConfigAbspath(partitionDir),
|
|
75
75
|
toPartitionCfg(
|
|
76
|
-
SanitizedPath.create(
|
|
76
|
+
SanitizedPath.create(relative(partitionDir, partitionDir)),
|
|
77
77
|
SanitizedPath.create(relative(partitionDir, getRootConfigAbspath(projectDir))),
|
|
78
78
|
),
|
|
79
79
|
);
|
|
80
|
-
};
|
|
81
80
|
|
|
82
81
|
export const ensurePartitionExists = async (
|
|
83
82
|
partitionDir: SanitizedAbsPath.t,
|
|
@@ -104,13 +103,13 @@ export const ensureSelectedPartitionExists = (args: CustomRequestArgs, forceCrea
|
|
|
104
103
|
args.partition
|
|
105
104
|
? ensurePartitionExists(
|
|
106
105
|
SanitizedAbsPath.create(join(args.projectDir, args.partition)),
|
|
107
|
-
|
|
106
|
+
args.projectDir,
|
|
108
107
|
forceCreate,
|
|
109
108
|
)
|
|
110
109
|
: ensurePartitionExists(
|
|
111
110
|
SanitizedAbsPath.create(
|
|
112
111
|
join(args.projectDir, getTestsRootDir(args.config)),
|
|
113
112
|
),
|
|
114
|
-
|
|
113
|
+
args.projectDir,
|
|
115
114
|
forceCreate,
|
|
116
115
|
);
|
package/config.ts
CHANGED
|
@@ -1,9 +1,50 @@
|
|
|
1
1
|
import { LoadedConfig } from '@taqueria/node-sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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>;
|
|
8
32
|
|
|
9
|
-
export
|
|
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
|
+
}
|
|
50
|
+
};
|
package/contractTestTemplate.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// import { normalizeContractName } from '@taqueria/plugin-contract-types/src/generator/contract-name';
|
|
2
|
-
import {
|
|
2
|
+
import { 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,13 +12,12 @@ import { CustomRequestArgs, ensureSelectedPartitionExists, getPartitionAbspath,
|
|
|
12
12
|
type Generator = ReturnType<typeof createTestingCodeGenerator>;
|
|
13
13
|
|
|
14
14
|
interface Opts extends CustomRequestArgs {
|
|
15
|
-
readonly michelsonArtifact
|
|
15
|
+
readonly michelsonArtifact: string;
|
|
16
16
|
readonly partition?: string;
|
|
17
17
|
readonly name?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const getMichelsonAbspath = (parsedArgs: Opts) =>
|
|
21
|
-
join(parsedArgs.config.artifactsDir ?? 'artifacts', parsedArgs.michelsonArtifact!);
|
|
20
|
+
const getMichelsonAbspath = (parsedArgs: Opts) => join(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);
|
|
22
21
|
|
|
23
22
|
const ensureMichelsonExists = (parsedArgs: Opts) => {
|
|
24
23
|
const abspath = getMichelsonAbspath(parsedArgs);
|
|
@@ -36,7 +35,7 @@ const getTypesOutputAbspath = (parsedArgs: Opts) => join(getPartition(parsedArgs
|
|
|
36
35
|
|
|
37
36
|
const generateContractTypes = (parsedArgs: Opts) =>
|
|
38
37
|
generateContractTypesProcessContractFiles({
|
|
39
|
-
inputTzContractDirectory: parsedArgs.config.artifactsDir
|
|
38
|
+
inputTzContractDirectory: parsedArgs.config.artifactsDir,
|
|
40
39
|
inputFiles: [getMichelsonAbspath(parsedArgs)],
|
|
41
40
|
outputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),
|
|
42
41
|
format: 'tz',
|
|
@@ -46,7 +45,7 @@ const generateContractTypes = (parsedArgs: Opts) =>
|
|
|
46
45
|
const getContractName = (parsedArgs: Opts) =>
|
|
47
46
|
parsedArgs.name
|
|
48
47
|
? parsedArgs.name.trim().replace(/\.ts$/, '')
|
|
49
|
-
: basename(parsedArgs.michelsonArtifact
|
|
48
|
+
: basename(parsedArgs.michelsonArtifact, '.tz');
|
|
50
49
|
|
|
51
50
|
const generateTestSuite = (parsedArgs: Opts) => {
|
|
52
51
|
const michelsonAbspath = getMichelsonAbspath(parsedArgs);
|
|
@@ -111,14 +110,11 @@ ${
|
|
|
111
110
|
`;
|
|
112
111
|
};
|
|
113
112
|
|
|
114
|
-
export default (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.then(generateTestSuite)
|
|
122
|
-
.then((outFile: string) => sendAsyncRes(`Test suite generated: ${outFile}`))
|
|
123
|
-
: sendAsyncErr(`No michelson artifact provided`);
|
|
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}`));
|
|
124
120
|
};
|
package/index.cjs
CHANGED
|
@@ -1,24 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
// index.ts
|
|
4
|
-
var
|
|
4
|
+
var import_node_sdk5 = require("@taqueria/node-sdk");
|
|
5
5
|
|
|
6
6
|
// common.ts
|
|
7
|
-
var
|
|
7
|
+
var import_node_sdk2 = 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
|
|
12
46
|
var toRequestArgs = (args) => {
|
|
13
47
|
const config = {
|
|
14
|
-
...args.config,
|
|
15
48
|
jest: {
|
|
16
49
|
testsRootDir: "tests"
|
|
17
|
-
}
|
|
50
|
+
},
|
|
51
|
+
...args.config
|
|
18
52
|
};
|
|
19
53
|
return {
|
|
20
54
|
...args,
|
|
21
|
-
config
|
|
55
|
+
config: create(config)
|
|
22
56
|
};
|
|
23
57
|
};
|
|
24
58
|
var getDefaultConfig = (defaultConfig) => {
|
|
@@ -49,39 +83,37 @@ module.exports = {
|
|
|
49
83
|
`;
|
|
50
84
|
var getPartitionAbspath = (partitionDir) => import_types.SanitizedAbsPath.create(partitionDir);
|
|
51
85
|
var getPartitionConfigAbspath = (partitionDir) => import_types.SanitizedAbsPath.create((0, import_path.join)(partitionDir, "jest.config.js"));
|
|
52
|
-
var initPartition = (partitionDir, projectDir) =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
);
|
|
60
|
-
};
|
|
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
|
+
);
|
|
61
93
|
var ensurePartitionExists = async (partitionDir, projectDir, forceCreate = false) => ensureRootConfigExists(projectDir).then((_) => (0, import_promises.stat)(partitionDir)).then(
|
|
62
|
-
(stats) => stats.isFile() ? (0,
|
|
94
|
+
(stats) => stats.isFile() ? (0, import_node_sdk2.sendAsyncErr)(`${partitionDir} is an invalid partition directory`) : stats
|
|
63
95
|
).catch((_) => (0, import_promises.mkdir)(partitionDir, { recursive: true })).then((_) => getPartitionConfigAbspath(partitionDir)).then(
|
|
64
96
|
(partitionCfgAbsPath) => (0, import_promises.stat)(partitionCfgAbsPath).then((_) => forceCreate ? initPartition(partitionDir, projectDir) : void 0).catch((_) => initPartition(partitionDir, projectDir))
|
|
65
97
|
).then((_) => getPartitionConfigAbspath(partitionDir));
|
|
66
98
|
var ensureSelectedPartitionExists = (args, forceCreate = false) => args.partition ? ensurePartitionExists(
|
|
67
99
|
import_types.SanitizedAbsPath.create((0, import_path.join)(args.projectDir, args.partition)),
|
|
68
|
-
|
|
100
|
+
args.projectDir,
|
|
69
101
|
forceCreate
|
|
70
102
|
) : ensurePartitionExists(
|
|
71
103
|
import_types.SanitizedAbsPath.create(
|
|
72
104
|
(0, import_path.join)(args.projectDir, getTestsRootDir(args.config))
|
|
73
105
|
),
|
|
74
|
-
|
|
106
|
+
args.projectDir,
|
|
75
107
|
forceCreate
|
|
76
108
|
);
|
|
77
109
|
|
|
78
110
|
// contractTestTemplate.ts
|
|
79
|
-
var
|
|
111
|
+
var import_node_sdk3 = require("@taqueria/node-sdk");
|
|
80
112
|
var import_cli_process = require("@taqueria/plugin-contract-types/src/cli-process.js");
|
|
81
113
|
var import_testing_code_generator = require("@taqueria/plugin-contract-types/src/generator/testing-code-generator.js");
|
|
82
114
|
var import_promises2 = require("fs/promises");
|
|
83
115
|
var import_path2 = require("path");
|
|
84
|
-
var getMichelsonAbspath = (parsedArgs) => (0, import_path2.join)(parsedArgs.config.artifactsDir
|
|
116
|
+
var getMichelsonAbspath = (parsedArgs) => (0, import_path2.join)(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);
|
|
85
117
|
var ensureMichelsonExists = (parsedArgs) => {
|
|
86
118
|
const abspath = getMichelsonAbspath(parsedArgs);
|
|
87
119
|
return (0, import_promises2.stat)(abspath).then(() => parsedArgs).catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run "taq compile"?`));
|
|
@@ -92,7 +124,7 @@ var getPartition = (parsedArgs) => {
|
|
|
92
124
|
};
|
|
93
125
|
var getTypesOutputAbspath = (parsedArgs) => (0, import_path2.join)(getPartition(parsedArgs), "types");
|
|
94
126
|
var generateContractTypes = (parsedArgs) => (0, import_cli_process.generateContractTypesProcessContractFiles)({
|
|
95
|
-
inputTzContractDirectory: parsedArgs.config.artifactsDir
|
|
127
|
+
inputTzContractDirectory: parsedArgs.config.artifactsDir,
|
|
96
128
|
inputFiles: [getMichelsonAbspath(parsedArgs)],
|
|
97
129
|
outputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),
|
|
98
130
|
format: "tz",
|
|
@@ -151,13 +183,12 @@ ${methodCalls.map((x) => `
|
|
|
151
183
|
`).join("")}});
|
|
152
184
|
`;
|
|
153
185
|
};
|
|
154
|
-
var contractTestTemplate_default = (
|
|
155
|
-
|
|
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`);
|
|
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}`));
|
|
157
188
|
};
|
|
158
189
|
|
|
159
190
|
// proxy.ts
|
|
160
|
-
var
|
|
191
|
+
var import_node_sdk4 = require("@taqueria/node-sdk");
|
|
161
192
|
var import_execa = require("execa");
|
|
162
193
|
var execCmd = (cmd, args) => {
|
|
163
194
|
var _a, _b;
|
|
@@ -182,24 +213,24 @@ var proxy_default = async (args) => {
|
|
|
182
213
|
process.exit(child.exitCode);
|
|
183
214
|
});
|
|
184
215
|
}
|
|
185
|
-
return (0,
|
|
216
|
+
return (0, import_node_sdk4.sendAsyncRes)("Initialized successfully.");
|
|
186
217
|
});
|
|
187
218
|
};
|
|
188
219
|
|
|
189
220
|
// index.ts
|
|
190
|
-
|
|
221
|
+
import_node_sdk5.Plugin.create((requestArgs) => ({
|
|
191
222
|
schema: "0.1",
|
|
192
223
|
version: "0.4.0",
|
|
193
224
|
alias: "jest",
|
|
194
225
|
tasks: [
|
|
195
|
-
|
|
226
|
+
import_node_sdk5.Task.create({
|
|
196
227
|
task: "test",
|
|
197
228
|
command: "test [partition]",
|
|
198
229
|
description: "Setup a directory as a partition to run Jest tests",
|
|
199
230
|
aliases: ["jest"],
|
|
200
231
|
handler: "proxy",
|
|
201
232
|
positionals: [
|
|
202
|
-
|
|
233
|
+
import_node_sdk5.PositionalArg.create({
|
|
203
234
|
placeholder: "partition",
|
|
204
235
|
description: "Name of the partition for these tests",
|
|
205
236
|
defaultValue: "tests",
|
|
@@ -207,13 +238,13 @@ import_node_sdk4.Plugin.create((requestArgs) => ({
|
|
|
207
238
|
})
|
|
208
239
|
],
|
|
209
240
|
options: [
|
|
210
|
-
|
|
241
|
+
import_node_sdk5.Option.create({
|
|
211
242
|
flag: "init",
|
|
212
243
|
shortFlag: "i",
|
|
213
244
|
description: "Initializes the partition for Jest",
|
|
214
245
|
boolean: true
|
|
215
246
|
}),
|
|
216
|
-
|
|
247
|
+
import_node_sdk5.Option.create({
|
|
217
248
|
flag: "testPattern",
|
|
218
249
|
shortFlag: "t",
|
|
219
250
|
description: "Run test files that match the provided pattern"
|
|
@@ -222,11 +253,11 @@ import_node_sdk4.Plugin.create((requestArgs) => ({
|
|
|
222
253
|
})
|
|
223
254
|
],
|
|
224
255
|
templates: [
|
|
225
|
-
|
|
256
|
+
import_node_sdk5.Template.create({
|
|
226
257
|
template: "contract-test",
|
|
227
258
|
command: "contract-test <michelsonArtifact>",
|
|
228
259
|
positionals: [
|
|
229
|
-
|
|
260
|
+
import_node_sdk5.PositionalArg.create({
|
|
230
261
|
placeholder: "michelsonArtifact",
|
|
231
262
|
description: "Name of the michelson contract (artifact) to generate tests for",
|
|
232
263
|
required: true,
|
|
@@ -234,7 +265,7 @@ import_node_sdk4.Plugin.create((requestArgs) => ({
|
|
|
234
265
|
})
|
|
235
266
|
],
|
|
236
267
|
options: [
|
|
237
|
-
|
|
268
|
+
import_node_sdk5.Option.create({
|
|
238
269
|
flag: "partition",
|
|
239
270
|
description: "Partition to place generated test suite",
|
|
240
271
|
type: "string",
|
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) =>\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,mBAAmB,CAAC,kBAAiC;AACjE,QAAM,WAAW,EAAE,GAAG,6BAAU,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,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;AAAA;AAAA;AAAA;AAAA;AAAA,WAKrB;AAAA;AAAA;AAAA;AAKJ,IAAM,sBAAsB,CAAC,iBAAyB,8BAAiB,OAAO,YAAY;AAE1F,IAAM,4BAA4B,CAAC,iBACzC,8BAAiB,WAAO,kBAAK,cAAc,gBAAgB,CAAC;AAEtD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AAA,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","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,IAAAC,mBAAi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ACR,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"]}
|
package/index.js
CHANGED
|
@@ -7,16 +7,50 @@ 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
|
|
10
44
|
var toRequestArgs = (args) => {
|
|
11
45
|
const config = {
|
|
12
|
-
...args.config,
|
|
13
46
|
jest: {
|
|
14
47
|
testsRootDir: "tests"
|
|
15
|
-
}
|
|
48
|
+
},
|
|
49
|
+
...args.config
|
|
16
50
|
};
|
|
17
51
|
return {
|
|
18
52
|
...args,
|
|
19
|
-
config
|
|
53
|
+
config: create(config)
|
|
20
54
|
};
|
|
21
55
|
};
|
|
22
56
|
var getDefaultConfig = (defaultConfig) => {
|
|
@@ -47,15 +81,13 @@ module.exports = {
|
|
|
47
81
|
`;
|
|
48
82
|
var getPartitionAbspath = (partitionDir) => SanitizedAbsPath.create(partitionDir);
|
|
49
83
|
var getPartitionConfigAbspath = (partitionDir) => SanitizedAbsPath.create(join(partitionDir, "jest.config.js"));
|
|
50
|
-
var initPartition = (partitionDir, projectDir) =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
};
|
|
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
|
+
);
|
|
59
91
|
var ensurePartitionExists = async (partitionDir, projectDir, forceCreate = false) => ensureRootConfigExists(projectDir).then((_) => stat(partitionDir)).then(
|
|
60
92
|
(stats) => stats.isFile() ? sendAsyncErr(`${partitionDir} is an invalid partition directory`) : stats
|
|
61
93
|
).catch((_) => mkdir(partitionDir, { recursive: true })).then((_) => getPartitionConfigAbspath(partitionDir)).then(
|
|
@@ -63,18 +95,18 @@ var ensurePartitionExists = async (partitionDir, projectDir, forceCreate = false
|
|
|
63
95
|
).then((_) => getPartitionConfigAbspath(partitionDir));
|
|
64
96
|
var ensureSelectedPartitionExists = (args, forceCreate = false) => args.partition ? ensurePartitionExists(
|
|
65
97
|
SanitizedAbsPath.create(join(args.projectDir, args.partition)),
|
|
66
|
-
|
|
98
|
+
args.projectDir,
|
|
67
99
|
forceCreate
|
|
68
100
|
) : ensurePartitionExists(
|
|
69
101
|
SanitizedAbsPath.create(
|
|
70
102
|
join(args.projectDir, getTestsRootDir(args.config))
|
|
71
103
|
),
|
|
72
|
-
|
|
104
|
+
args.projectDir,
|
|
73
105
|
forceCreate
|
|
74
106
|
);
|
|
75
107
|
|
|
76
108
|
// contractTestTemplate.ts
|
|
77
|
-
import {
|
|
109
|
+
import { sendAsyncRes as sendAsyncRes2 } from "@taqueria/node-sdk";
|
|
78
110
|
import { generateContractTypesProcessContractFiles } from "@taqueria/plugin-contract-types/src/cli-process.js";
|
|
79
111
|
import {
|
|
80
112
|
createTestingCodeGenerator,
|
|
@@ -82,7 +114,7 @@ import {
|
|
|
82
114
|
} from "@taqueria/plugin-contract-types/src/generator/testing-code-generator.js";
|
|
83
115
|
import { readFile, stat as stat2, writeFile as writeFile2 } from "fs/promises";
|
|
84
116
|
import { basename, join as join2 } from "path";
|
|
85
|
-
var getMichelsonAbspath = (parsedArgs) => join2(parsedArgs.config.artifactsDir
|
|
117
|
+
var getMichelsonAbspath = (parsedArgs) => join2(parsedArgs.config.artifactsDir, parsedArgs.michelsonArtifact);
|
|
86
118
|
var ensureMichelsonExists = (parsedArgs) => {
|
|
87
119
|
const abspath = getMichelsonAbspath(parsedArgs);
|
|
88
120
|
return stat2(abspath).then(() => parsedArgs).catch(() => Promise.reject(`${abspath} does not exist. Perhaps you need to run "taq compile"?`));
|
|
@@ -93,7 +125,7 @@ var getPartition = (parsedArgs) => {
|
|
|
93
125
|
};
|
|
94
126
|
var getTypesOutputAbspath = (parsedArgs) => join2(getPartition(parsedArgs), "types");
|
|
95
127
|
var generateContractTypes = (parsedArgs) => generateContractTypesProcessContractFiles({
|
|
96
|
-
inputTzContractDirectory: parsedArgs.config.artifactsDir
|
|
128
|
+
inputTzContractDirectory: parsedArgs.config.artifactsDir,
|
|
97
129
|
inputFiles: [getMichelsonAbspath(parsedArgs)],
|
|
98
130
|
outputTypescriptDirectory: getTypesOutputAbspath(parsedArgs),
|
|
99
131
|
format: "tz",
|
|
@@ -152,9 +184,8 @@ ${methodCalls.map((x) => `
|
|
|
152
184
|
`).join("")}});
|
|
153
185
|
`;
|
|
154
186
|
};
|
|
155
|
-
var contractTestTemplate_default = (
|
|
156
|
-
|
|
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`);
|
|
187
|
+
var contractTestTemplate_default = (parsedArgs) => {
|
|
188
|
+
return ensureMichelsonExists(parsedArgs).then(ensureSelectedPartitionExists).then(() => parsedArgs).then(generateContractTypes).then(generateTestSuite).then((outFile) => sendAsyncRes2(`Test suite generated: ${outFile}`));
|
|
158
189
|
};
|
|
159
190
|
|
|
160
191
|
// proxy.ts
|
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) =>\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,CAAC,WAAuB;AACtD,SAAO,OAAO,KAAK;AACpB;AAEO,IAAM,iBAAiB,CAAC,kBAAmC,sBAAuC;AAAA,gCACzE;AAAA;AAAA;AAAA;AAAA;AAAA,WAKrB;AAAA;AAAA;AAAA;AAKJ,IAAM,sBAAsB,CAAC,iBAAyB,iBAAiB,OAAO,YAAY;AAE1F,IAAM,4BAA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;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","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,eAAe,UAAU,SAAO,GAAiB;AAEhE,IAAM,SAAS,CAAC,UAA8B;AACpD,MAAI;AACH,UAAM,SAAS,OAAO,MAAM,KAAK;AACjC,WAAO;AAAA,EACR,QAAE;AACD,UAAM;AAAA,EACP;AACD;;;ADjCO,IAAM,gBAAgB,CAAC,SAA2C;AACxE,QAAM,SAAS;AAAA,IACd,MAAM;AAAA,MACL,cAAc;AAAA,IACf;AAAA,IACA,GAAG,KAAK;AAAA,EACT;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,QAAmB,OAAO,MAAM;AAAA,EACjC;AACD;AAEO,IAAM,mBAAmB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S;AAAA,EACT,OAAO;AAAA,EACP,OAAO;AAAA,IACN,KAAK,OAAO;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,MACT,aAAa;AAAA,MACb,SAAS,CAAC,MAAM;AAAA,MAChB,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,cAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,cAAc;AAAA,UACd,MAAM;AAAA,QACP,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aAAa;AAAA,UACb,SAAS;AAAA,QACV,CAAC;AAAA,QACD,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,WAAW;AAAA,UACX,aAAa;AAAA,QACd,CAAC;AAAA,MACF;AAAA,IACD,CAAC;AAAA,EACF;AAAA,EACA,WAAW;AAAA,IACV,SAAS,OAAO;AAAA,MACf,UAAU;AAAA,MACV,SAAS;AAAA,MACT,aAAa;AAAA,QACZ,cAAc,OAAO;AAAA,UACpB,aAAa;AAAA,UACb,aAAa;AAAA,UACb,UAAU;AAAA,UACV,MAAM;AAAA,QACP,CAAC;AAAA,MACF;AAAA,MACA,SAAS;AAAA,QACR,OAAO,OAAO;AAAA,UACb,MAAM;AAAA,UACN,aAAa;AAAA,UACb,MAAM;AAAA,UACN,cAAc,cAAc,WAAW,EAAE,OAAO,KAAK;AAAA,QACtD,CAAC;AAAA,MACF;AAAA,MACA,aAAa;AAAA,MACb,SAAS;AAAA,IACV,CAAC;AAAA,EACF;AAAA,EACA;AACD,IAAI,QAAQ,IAAI;","names":["sendAsyncRes","stat","writeFile","join","join","stat","writeFile","sendAsyncRes","sendAsyncRes","sendAsyncRes"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/plugin-jest",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.11-rc",
|
|
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.25.
|
|
30
|
+
"@taqueria/node-sdk": "^0.25.11-rc",
|
|
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';
|
|
2
|
+
import { RequestArgs } from '@taqueria/node-sdk/types';
|
|
3
3
|
import { execa } from 'execa';
|
|
4
4
|
import { CustomRequestArgs, ensureSelectedPartitionExists, toRequestArgs } from './common';
|
|
5
5
|
|
package/tsconfig.json
CHANGED
|
@@ -12,9 +12,7 @@
|
|
|
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": [
|
|
16
|
-
"ES2021.String"
|
|
17
|
-
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
18
16
|
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
19
17
|
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
20
18
|
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
@@ -79,7 +77,7 @@
|
|
|
79
77
|
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
80
78
|
|
|
81
79
|
/* Type Checking */
|
|
82
|
-
"strict": true
|
|
80
|
+
"strict": true /* Enable all strict type-checking options. */
|
|
83
81
|
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
|
|
84
82
|
// "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
|
|
85
83
|
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
@@ -101,6 +99,6 @@
|
|
|
101
99
|
|
|
102
100
|
/* Completeness */
|
|
103
101
|
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
104
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
102
|
+
// "skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
105
103
|
}
|
|
106
104
|
}
|