ic-mops 0.39.2 → 0.41.0
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/.DS_Store +0 -0
- package/.eslintrc.json +0 -0
- package/.gitignore +1 -0
- package/.npmrc +2 -1
- package/CHANGELOG.md +8 -0
- package/DEVELOPMENT.md +25 -0
- package/README.md +0 -0
- package/api/actors.ts +2 -2
- package/api/downloadPackageFiles.ts +9 -6
- package/api/getHighestVersion.ts +1 -1
- package/api/index.ts +0 -0
- package/api/network.ts +1 -1
- package/api/resolveVersion.ts +1 -1
- package/bundle/bench/bench-canister.mo +87 -0
- package/bundle/bench/user-bench.mo +14 -0
- package/bundle/bin/moc-wrapper.sh +3 -0
- package/bundle/bin/mops.js +3 -0
- package/bundle/cli.js +88 -0
- package/bundle/cli.tgz +0 -0
- package/bundle/declarations/bench/bench.did +26 -0
- package/bundle/declarations/bench/bench.did.d.ts +29 -0
- package/bundle/declarations/bench/bench.did.js +26 -0
- package/bundle/declarations/bench/index.d.ts +50 -0
- package/bundle/declarations/bench/index.js +41 -0
- package/bundle/declarations/main/index.d.ts +50 -0
- package/bundle/declarations/main/index.js +41 -0
- package/bundle/declarations/main/main.did +426 -0
- package/bundle/declarations/main/main.did.d.ts +352 -0
- package/bundle/declarations/main/main.did.js +404 -0
- package/bundle/declarations/storage/index.d.ts +50 -0
- package/bundle/declarations/storage/index.js +30 -0
- package/bundle/declarations/storage/storage.did +46 -0
- package/bundle/declarations/storage/storage.did.d.ts +37 -0
- package/bundle/declarations/storage/storage.did.js +38 -0
- package/bundle/package.json +31 -0
- package/bundle/templates/README.md +13 -0
- package/bundle/templates/licenses/Apache-2.0 +202 -0
- package/bundle/templates/licenses/Apache-2.0-NOTICE +13 -0
- package/bundle/templates/licenses/MIT +21 -0
- package/bundle/templates/mops-publish.yml +17 -0
- package/bundle/templates/mops-test.yml +22 -0
- package/bundle/templates/src/lib.mo +15 -0
- package/bundle/templates/test/lib.test.mo +4 -0
- package/bundle-package-json.ts +14 -0
- package/cache.ts +3 -3
- package/cli.ts +25 -21
- package/commands/add.ts +6 -6
- package/commands/available-updates.ts +2 -2
- package/commands/bench/bench-canister.mo +0 -0
- package/commands/bench/user-bench.mo +0 -0
- package/commands/bench-replica.ts +10 -10
- package/commands/bench.ts +96 -56
- package/commands/bump.ts +2 -2
- package/commands/docs.ts +1 -1
- package/commands/import-identity.ts +2 -2
- package/commands/init.ts +9 -9
- package/commands/install-all.ts +4 -4
- package/commands/install-local.ts +1 -1
- package/commands/install.ts +2 -2
- package/commands/outdated.ts +0 -0
- package/commands/publish.ts +34 -35
- package/commands/remove.ts +8 -8
- package/commands/search.ts +2 -2
- package/commands/self.ts +75 -0
- package/commands/sources.ts +0 -0
- package/commands/sync.ts +8 -8
- package/commands/template.ts +11 -12
- package/commands/test/mmf1.ts +18 -18
- package/commands/test/reporters/compact-reporter.ts +5 -5
- package/commands/test/reporters/files-reporter.ts +3 -3
- package/commands/test/reporters/reporter.ts +3 -3
- package/commands/test/reporters/silent-reporter.ts +4 -4
- package/commands/test/reporters/verbose-reporter.ts +3 -3
- package/commands/test/test.ts +10 -10
- package/commands/test/utils.ts +1 -1
- package/commands/toolchain/index.ts +9 -9
- package/commands/toolchain/moc.ts +2 -2
- package/commands/toolchain/pocket-ic.ts +6 -31
- package/commands/toolchain/toolchain-utils.ts +11 -11
- package/commands/toolchain/wasmtime.ts +2 -2
- package/commands/transfer-ownership.ts +2 -2
- package/commands/update.ts +4 -4
- package/commands/user.ts +2 -2
- package/commands/whoami.ts +0 -0
- package/declarations/bench/bench.did.d.ts +3 -0
- package/declarations/main/main.did +27 -1
- package/declarations/main/main.did.d.ts +26 -1
- package/declarations/main/main.did.js +27 -1
- package/declarations/storage/index.d.ts +0 -0
- package/declarations/storage/index.js +0 -0
- package/declarations/storage/storage.did +0 -0
- package/declarations/storage/storage.did.d.ts +0 -0
- package/declarations/storage/storage.did.js +0 -0
- package/dist/api/downloadPackageFiles.d.ts +1 -1
- package/dist/api/downloadPackageFiles.js +4 -0
- package/dist/bin/moc-wrapper.sh +3 -0
- package/dist/bin/mops.d.ts +1 -1
- package/dist/bin/mops.js +2 -1
- package/dist/bundle-package-json.d.ts +1 -0
- package/dist/bundle-package-json.js +11 -0
- package/dist/check-requirements.d.ts +3 -0
- package/dist/check-requirements.js +39 -0
- package/dist/cli.js +19 -18
- package/dist/commands/bench/bench-canister.mo +0 -0
- package/dist/commands/bench/user-bench.mo +0 -0
- package/dist/commands/bench-replica.d.ts +3 -1
- package/dist/commands/bench-replica.js +2 -2
- package/dist/commands/bench.d.ts +5 -2
- package/dist/commands/bench.js +66 -29
- package/dist/commands/init.js +1 -1
- package/dist/commands/publish.d.ts +1 -0
- package/dist/commands/publish.js +25 -25
- package/dist/commands/self.d.ts +3 -0
- package/dist/commands/self.js +62 -0
- package/dist/commands/template.js +9 -10
- package/dist/commands/test/mmf1.js +1 -1
- package/dist/commands/test/test.js +2 -2
- package/dist/commands/toolchain/pocket-ic.d.ts +1 -5
- package/dist/commands/toolchain/pocket-ic.js +4 -27
- package/dist/commands/toolchain/toolchain-utils.d.ts +1 -1
- package/dist/commands/toolchain/toolchain-utils.js +7 -7
- package/dist/commands/transfer-ownership.js +1 -1
- package/dist/declarations/bench/bench.did.d.ts +3 -0
- package/dist/declarations/main/main.did +27 -1
- package/dist/declarations/main/main.did.d.ts +26 -1
- package/dist/declarations/main/main.did.js +27 -1
- package/dist/declarations/storage/index.d.ts +0 -0
- package/dist/declarations/storage/index.js +0 -0
- package/dist/declarations/storage/storage.did +0 -0
- package/dist/declarations/storage/storage.did.d.ts +0 -0
- package/dist/declarations/storage/storage.did.js +0 -0
- package/dist/helpers/find-changelog-entry.d.ts +1 -0
- package/dist/helpers/find-changelog-entry.js +24 -0
- package/dist/mops.d.ts +1 -0
- package/dist/mops.js +5 -1
- package/dist/package.json +20 -26
- package/dist/release-cli.d.ts +1 -0
- package/dist/release-cli.js +37 -0
- package/dist/remove-scripts.d.ts +1 -0
- package/dist/remove-scripts.js +5 -0
- package/dist/templates/README.md +0 -0
- package/dist/templates/licenses/Apache-2.0 +0 -0
- package/dist/templates/licenses/Apache-2.0-NOTICE +0 -0
- package/dist/templates/licenses/MIT +0 -0
- package/dist/templates/mops-publish.yml +0 -0
- package/dist/templates/mops-test.yml +0 -0
- package/dist/templates/src/lib.mo +0 -0
- package/dist/templates/test/lib.test.mo +0 -0
- package/dist/templates.d.ts +1 -0
- package/dist/templates.js +4 -0
- package/dist/vessel.js +1 -1
- package/global.d.ts +0 -0
- package/helpers/find-changelog-entry.ts +27 -0
- package/helpers/get-dfx-version.ts +1 -1
- package/helpers/get-moc-path.ts +1 -1
- package/helpers/get-moc-version.ts +1 -1
- package/integrity.ts +16 -16
- package/mops.ts +22 -17
- package/notify-installs.ts +2 -2
- package/package.json +28 -19
- package/parallel.ts +1 -1
- package/pem.ts +5 -5
- package/release-cli.ts +62 -0
- package/remove-scripts.ts +6 -0
- package/resolve-packages.ts +9 -9
- package/templates/README.md +0 -0
- package/templates/licenses/Apache-2.0 +0 -0
- package/templates/licenses/Apache-2.0-NOTICE +0 -0
- package/templates/licenses/MIT +0 -0
- package/templates/mops-publish.yml +0 -0
- package/templates/mops-test.yml +0 -0
- package/templates/src/lib.mo +0 -0
- package/templates/test/lib.test.mo +0 -0
- package/templates.ts +5 -0
- package/tsconfig.json +1 -1
- package/types.ts +25 -25
- package/vessel.ts +16 -16
- package/commands/self-update.ts +0 -6
- package/dist/commands/replica.d.ts +0 -36
- package/dist/commands/replica.js +0 -103
- package/dist/commands/self-update.d.ts +0 -3
- package/dist/commands/self-update.js +0 -5
- /package/bin/{mops.ts → mops.js} +0 -0
package/commands/bench.ts
CHANGED
|
@@ -8,7 +8,7 @@ import logUpdate from 'log-update';
|
|
|
8
8
|
import {execaCommand} from 'execa';
|
|
9
9
|
import stringWidth from 'string-width';
|
|
10
10
|
|
|
11
|
-
import {getRootDir} from '../mops.js';
|
|
11
|
+
import {getRootDir, readConfig} from '../mops.js';
|
|
12
12
|
import {parallel} from '../parallel.js';
|
|
13
13
|
import {absToRel} from './test/utils.js';
|
|
14
14
|
import {getMocVersion} from '../helpers/get-moc-version.js';
|
|
@@ -16,7 +16,8 @@ import {getDfxVersion} from '../helpers/get-dfx-version.js';
|
|
|
16
16
|
import {getMocPath} from '../helpers/get-moc-path.js';
|
|
17
17
|
import {sources} from './sources.js';
|
|
18
18
|
|
|
19
|
-
import {
|
|
19
|
+
import {Benchmark, Benchmarks} from '../declarations/main/main.did.js';
|
|
20
|
+
import {BenchResult, _SERVICE} from '../declarations/bench/bench.did.js';
|
|
20
21
|
import {BenchReplica} from './bench-replica.js';
|
|
21
22
|
|
|
22
23
|
let ignore = [
|
|
@@ -32,31 +33,42 @@ let globConfig = {
|
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
type BenchOptions = {
|
|
35
|
-
replica: 'dfx' | 'pocket-ic',
|
|
36
|
-
replicaVersion: string,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
replica : 'dfx' | 'pocket-ic',
|
|
37
|
+
replicaVersion : string,
|
|
38
|
+
compiler : 'moc',
|
|
39
|
+
compilerVersion : string,
|
|
40
|
+
gc : 'copying' | 'compacting' | 'generational' | 'incremental',
|
|
41
|
+
forceGc : boolean,
|
|
42
|
+
save : boolean,
|
|
43
|
+
compare : boolean,
|
|
44
|
+
verbose : boolean,
|
|
45
|
+
silent : boolean,
|
|
46
|
+
|
|
43
47
|
};
|
|
44
48
|
|
|
45
|
-
export async function bench(filter = '', optionsArg: Partial<BenchOptions> = {}): Promise<
|
|
46
|
-
let defaultOptions: BenchOptions = {
|
|
49
|
+
export async function bench(filter = '', optionsArg : Partial<BenchOptions> = {}) : Promise<Benchmarks> {
|
|
50
|
+
let defaultOptions : BenchOptions = {
|
|
47
51
|
replica: 'dfx',
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
replicaVersion: '',
|
|
53
|
+
compiler: 'moc',
|
|
54
|
+
compilerVersion: getMocVersion(),
|
|
50
55
|
gc: 'copying',
|
|
51
56
|
forceGc: true,
|
|
52
57
|
save: false,
|
|
53
58
|
compare: false,
|
|
54
59
|
verbose: false,
|
|
60
|
+
silent: false,
|
|
55
61
|
};
|
|
56
62
|
|
|
57
|
-
let options: BenchOptions = {...defaultOptions, ...optionsArg};
|
|
63
|
+
let options : BenchOptions = {...defaultOptions, ...optionsArg};
|
|
58
64
|
|
|
59
|
-
|
|
65
|
+
if (options.replica == 'dfx') {
|
|
66
|
+
options.replicaVersion = getDfxVersion();
|
|
67
|
+
}
|
|
68
|
+
else if (options.replica == 'pocket-ic') {
|
|
69
|
+
let config = readConfig();
|
|
70
|
+
options.replicaVersion = config.toolchain?.['pocket-ic'] || '';
|
|
71
|
+
}
|
|
60
72
|
|
|
61
73
|
options.verbose && console.log(options);
|
|
62
74
|
|
|
@@ -70,12 +82,14 @@ export async function bench(filter = '', optionsArg: Partial<BenchOptions> = {})
|
|
|
70
82
|
let files = globSync(path.join(rootDir, globStr), globConfig);
|
|
71
83
|
if (!files.length) {
|
|
72
84
|
if (filter) {
|
|
73
|
-
console.log(`No benchmark files found for filter '${filter}'`);
|
|
74
|
-
return
|
|
85
|
+
options.silent || console.log(`No benchmark files found for filter '${filter}'`);
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
if (!options.silent) {
|
|
89
|
+
console.log('No *.bench.mo files found');
|
|
90
|
+
console.log('Put your benchmark code in \'bench\' directory in *.bench.mo files');
|
|
75
91
|
}
|
|
76
|
-
|
|
77
|
-
console.log('Put your benchmark code in \'bench\' directory in *.bench.mo files');
|
|
78
|
-
return false;
|
|
92
|
+
return [];
|
|
79
93
|
}
|
|
80
94
|
|
|
81
95
|
files.sort();
|
|
@@ -84,18 +98,20 @@ export async function bench(filter = '', optionsArg: Partial<BenchOptions> = {})
|
|
|
84
98
|
fs.rmSync(benchDir, {recursive: true, force: true});
|
|
85
99
|
fs.mkdirSync(benchDir, {recursive: true});
|
|
86
100
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
if (!options.silent) {
|
|
102
|
+
console.log('Benchmark files:');
|
|
103
|
+
for (let file of files) {
|
|
104
|
+
console.log(chalk.gray(`• ${absToRel(file)}`));
|
|
105
|
+
}
|
|
106
|
+
console.log('');
|
|
107
|
+
console.log('='.repeat(50));
|
|
108
|
+
console.log('');
|
|
90
109
|
}
|
|
91
|
-
console.log('');
|
|
92
|
-
console.log('='.repeat(50));
|
|
93
|
-
console.log('');
|
|
94
110
|
|
|
95
|
-
await replica.start();
|
|
111
|
+
await replica.start({silent: options.silent});
|
|
96
112
|
|
|
97
|
-
console.log('Deploying canisters...');
|
|
98
|
-
await parallel(os.cpus().length, files, async (file: string) => {
|
|
113
|
+
options.silent || console.log('Deploying canisters...');
|
|
114
|
+
await parallel(os.cpus().length, files, async (file : string) => {
|
|
99
115
|
try {
|
|
100
116
|
await deployBenchFile(file, options, replica);
|
|
101
117
|
}
|
|
@@ -106,12 +122,17 @@ export async function bench(filter = '', optionsArg: Partial<BenchOptions> = {})
|
|
|
106
122
|
}
|
|
107
123
|
});
|
|
108
124
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
let benchResults : Benchmarks = [];
|
|
126
|
+
|
|
127
|
+
await parallel(1, files, async (file : string) => {
|
|
128
|
+
if (!options.silent) {
|
|
129
|
+
console.log('\n' + '—'.repeat(50));
|
|
130
|
+
console.log(`\nRunning ${chalk.gray(absToRel(file))}...`);
|
|
131
|
+
console.log('');
|
|
132
|
+
}
|
|
113
133
|
try {
|
|
114
|
-
await runBenchFile(file, options, replica);
|
|
134
|
+
let benchResult = await runBenchFile(file, options, replica);
|
|
135
|
+
benchResults.push(benchResult);
|
|
115
136
|
}
|
|
116
137
|
catch (err) {
|
|
117
138
|
console.error('Unexpected error. Stopping replica...');
|
|
@@ -120,15 +141,15 @@ export async function bench(filter = '', optionsArg: Partial<BenchOptions> = {})
|
|
|
120
141
|
}
|
|
121
142
|
});
|
|
122
143
|
|
|
123
|
-
console.log('Stopping replica...');
|
|
144
|
+
options.silent || console.log('Stopping replica...');
|
|
124
145
|
await replica.stop();
|
|
125
146
|
|
|
126
147
|
fs.rmSync(benchDir, {recursive: true, force: true});
|
|
127
148
|
|
|
128
|
-
return
|
|
149
|
+
return benchResults;
|
|
129
150
|
}
|
|
130
151
|
|
|
131
|
-
function getMocArgs(options: BenchOptions): string {
|
|
152
|
+
function getMocArgs(options : BenchOptions) : string {
|
|
132
153
|
let args = '';
|
|
133
154
|
if (options.forceGc) {
|
|
134
155
|
args += ' --force-gc';
|
|
@@ -139,7 +160,7 @@ function getMocArgs(options: BenchOptions): string {
|
|
|
139
160
|
return args;
|
|
140
161
|
}
|
|
141
162
|
|
|
142
|
-
async function deployBenchFile(file: string, options: BenchOptions, replica: BenchReplica): Promise<void> {
|
|
163
|
+
async function deployBenchFile(file : string, options : BenchOptions, replica : BenchReplica) : Promise<void> {
|
|
143
164
|
let rootDir = getRootDir();
|
|
144
165
|
let tempDir = path.join(rootDir, '.mops/.bench/', path.parse(file).name);
|
|
145
166
|
let canisterName = path.parse(file).name;
|
|
@@ -173,12 +194,7 @@ async function deployBenchFile(file: string, options: BenchOptions, replica: Ben
|
|
|
173
194
|
options.verbose && console.timeEnd(`init ${canisterName}`);
|
|
174
195
|
}
|
|
175
196
|
|
|
176
|
-
|
|
177
|
-
schema: BenchSchema,
|
|
178
|
-
results: Map<string, BenchResult>,
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
async function runBenchFile(file: string, options: BenchOptions, replica: BenchReplica): Promise<RunBenchFileResult> {
|
|
197
|
+
async function runBenchFile(file : string, options : BenchOptions, replica : BenchReplica) : Promise<Benchmark> {
|
|
182
198
|
let rootDir = getRootDir();
|
|
183
199
|
let canisterName = path.parse(file).name;
|
|
184
200
|
|
|
@@ -186,7 +202,7 @@ async function runBenchFile(file: string, options: BenchOptions, replica: BenchR
|
|
|
186
202
|
let schema = await actor.getSchema();
|
|
187
203
|
|
|
188
204
|
// load previous results
|
|
189
|
-
let prevResults: Map<string, BenchResult> | undefined;
|
|
205
|
+
let prevResults : Map<string, BenchResult> | undefined;
|
|
190
206
|
let resultsJsonFile = path.join(rootDir, '.bench', `${path.parse(file).name}.json`);
|
|
191
207
|
if (options.compare) {
|
|
192
208
|
if (fs.existsSync(resultsJsonFile)) {
|
|
@@ -200,11 +216,14 @@ async function runBenchFile(file: string, options: BenchOptions, replica: BenchR
|
|
|
200
216
|
|
|
201
217
|
let results = new Map<string, BenchResult>();
|
|
202
218
|
|
|
203
|
-
let
|
|
219
|
+
let instructionsCells : bigint[][] = Array.from({length: schema.rows.length}, () => []);
|
|
220
|
+
let heapCells : bigint[][] = Array.from({length: schema.rows.length}, () => []);
|
|
221
|
+
|
|
222
|
+
let formatNumber = (n : bigint | number) : string => {
|
|
204
223
|
return n.toLocaleString('en-US').replaceAll(',', '_');
|
|
205
224
|
};
|
|
206
225
|
|
|
207
|
-
let getTable = (prop: keyof BenchResult): string => {
|
|
226
|
+
let getTable = (prop : keyof BenchResult) : string => {
|
|
208
227
|
let resArr = [['', ...schema.cols]];
|
|
209
228
|
|
|
210
229
|
for (let [_rowIndex, row] of schema.rows.entries()) {
|
|
@@ -222,7 +241,7 @@ async function runBenchFile(file: string, options: BenchOptions, replica: BenchR
|
|
|
222
241
|
let percent = (Number(res[prop]) - Number(prevRes[prop])) / Number(prevRes[prop]) * 100;
|
|
223
242
|
let sign = percent > 0 ? '+' : '';
|
|
224
243
|
let percentText = percent == 0 ? '0%' : sign + percent.toFixed(2) + '%';
|
|
225
|
-
let color: keyof typeof chalk = percent == 0 ? 'gray' : (percent > 0 ? 'red' : 'green');
|
|
244
|
+
let color : keyof typeof chalk = percent == 0 ? 'gray' : (percent > 0 ? 'red' : 'green');
|
|
226
245
|
diff = ` (${chalk[color](percentText)})`;
|
|
227
246
|
}
|
|
228
247
|
else {
|
|
@@ -255,18 +274,22 @@ async function runBenchFile(file: string, options: BenchOptions, replica: BenchR
|
|
|
255
274
|
`);
|
|
256
275
|
};
|
|
257
276
|
|
|
258
|
-
if (!process.env.CI) {
|
|
277
|
+
if (!process.env.CI && !options.silent) {
|
|
259
278
|
printResults();
|
|
260
279
|
}
|
|
261
280
|
|
|
262
281
|
// run all cells
|
|
263
282
|
for (let [rowIndex, row] of schema.rows.entries()) {
|
|
264
283
|
for (let [colIndex, col] of schema.cols.entries()) {
|
|
265
|
-
// let res = await actor.runCellQuery(BigInt(rowIndex), BigInt(colIndex));
|
|
266
|
-
// let res = await actor.runCellUpdate(BigInt(rowIndex), BigInt(colIndex));
|
|
267
284
|
let res = await actor.runCellUpdateAwait(BigInt(rowIndex), BigInt(colIndex));
|
|
268
285
|
results.set(`${row}:${col}`, res);
|
|
269
|
-
|
|
286
|
+
|
|
287
|
+
// @ts-ignore
|
|
288
|
+
instructionsCells[rowIndex][colIndex] = res.instructions;
|
|
289
|
+
// @ts-ignore
|
|
290
|
+
heapCells[rowIndex][colIndex] = res.rts_heap_size;
|
|
291
|
+
|
|
292
|
+
if (!process.env.CI && !options.silent) {
|
|
270
293
|
printResults();
|
|
271
294
|
}
|
|
272
295
|
}
|
|
@@ -280,9 +303,9 @@ async function runBenchFile(file: string, options: BenchOptions, replica: BenchR
|
|
|
280
303
|
// save results
|
|
281
304
|
if (options.save) {
|
|
282
305
|
console.log(`Saving results to ${chalk.gray(absToRel(resultsJsonFile))}`);
|
|
283
|
-
let json: Record<any, any> = {
|
|
306
|
+
let json : Record<any, any> = {
|
|
284
307
|
version: 1,
|
|
285
|
-
moc: options.
|
|
308
|
+
moc: options.compilerVersion,
|
|
286
309
|
replica: options.replica,
|
|
287
310
|
replicaVersion: options.replicaVersion,
|
|
288
311
|
gc: options.gc,
|
|
@@ -300,5 +323,22 @@ async function runBenchFile(file: string, options: BenchOptions, replica: BenchR
|
|
|
300
323
|
}, 2));
|
|
301
324
|
}
|
|
302
325
|
|
|
303
|
-
|
|
326
|
+
// for backend
|
|
327
|
+
return {
|
|
328
|
+
name: schema.name,
|
|
329
|
+
description: schema.description,
|
|
330
|
+
file: absToRel(file),
|
|
331
|
+
gc: options.gc,
|
|
332
|
+
forceGC: options.forceGc,
|
|
333
|
+
replica: options.replica,
|
|
334
|
+
replicaVersion: options.replicaVersion,
|
|
335
|
+
compiler: options.compiler,
|
|
336
|
+
compilerVersion: options.compilerVersion,
|
|
337
|
+
rows: schema.rows,
|
|
338
|
+
cols: schema.cols,
|
|
339
|
+
metrics: [
|
|
340
|
+
['instructions', instructionsCells],
|
|
341
|
+
['rts_heap_size', heapCells],
|
|
342
|
+
],
|
|
343
|
+
};
|
|
304
344
|
}
|
package/commands/bump.ts
CHANGED
|
@@ -2,7 +2,7 @@ import prompts from 'prompts';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import {checkConfigFile, readConfig, writeConfig} from '../mops.js';
|
|
4
4
|
|
|
5
|
-
export async function bump(part: string) {
|
|
5
|
+
export async function bump(part : string) {
|
|
6
6
|
if (!checkConfigFile()) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
@@ -44,7 +44,7 @@ export async function bump(part: string) {
|
|
|
44
44
|
console.log(`Updated version: ${chalk.green.bold(config.package.version)}`);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
function updateVersion(version: string, part: string) {
|
|
47
|
+
function updateVersion(version : string, part : string) {
|
|
48
48
|
let parts = version.split('.');
|
|
49
49
|
let idx = ['major', 'minor', 'patch'].indexOf(part);
|
|
50
50
|
if (!parts[idx]) {
|
package/commands/docs.ts
CHANGED
|
@@ -10,7 +10,7 @@ import streamToPromise from 'stream-to-promise';
|
|
|
10
10
|
import {getRootDir} from '../mops.js';
|
|
11
11
|
import {toolchain} from './toolchain/index.js';
|
|
12
12
|
|
|
13
|
-
let moDocPath: string;
|
|
13
|
+
let moDocPath : string;
|
|
14
14
|
|
|
15
15
|
export async function docs({silent = false} = {}) {
|
|
16
16
|
let rootDir = getRootDir();
|
|
@@ -7,10 +7,10 @@ import {globalConfigDir} from '../mops.js';
|
|
|
7
7
|
import {encrypt} from '../pem.js';
|
|
8
8
|
|
|
9
9
|
type ImportIdentityOptions = {
|
|
10
|
-
encrypt: boolean;
|
|
10
|
+
encrypt : boolean;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export async function importPem(data: string, options: ImportIdentityOptions = {encrypt: true}) {
|
|
13
|
+
export async function importPem(data : string, options : ImportIdentityOptions = {encrypt: true}) {
|
|
14
14
|
try {
|
|
15
15
|
if (!fs.existsSync(globalConfigDir)) {
|
|
16
16
|
fs.mkdirSync(globalConfigDir);
|
package/commands/init.ts
CHANGED
|
@@ -21,7 +21,7 @@ export async function init({yes = false} = {}) {
|
|
|
21
21
|
|
|
22
22
|
console.log('Initializing...');
|
|
23
23
|
|
|
24
|
-
let config: Config = {};
|
|
24
|
+
let config : Config = {};
|
|
25
25
|
|
|
26
26
|
if (yes) {
|
|
27
27
|
await applyInit({
|
|
@@ -36,7 +36,7 @@ export async function init({yes = false} = {}) {
|
|
|
36
36
|
|
|
37
37
|
// migrate from vessel
|
|
38
38
|
let vesselFile = path.join(process.cwd(), 'vessel.dhall');
|
|
39
|
-
let vesselConfig: VesselConfig = {dependencies: [], 'dev-dependencies': []};
|
|
39
|
+
let vesselConfig : VesselConfig = {dependencies: [], 'dev-dependencies': []};
|
|
40
40
|
|
|
41
41
|
if (existsSync(vesselFile)) {
|
|
42
42
|
console.log('Reading vessel.dhall file');
|
|
@@ -47,7 +47,7 @@ export async function init({yes = false} = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (vesselConfig.dependencies) {
|
|
50
|
-
let deps: Dependencies = {};
|
|
50
|
+
let deps : Dependencies = {};
|
|
51
51
|
deps = {};
|
|
52
52
|
|
|
53
53
|
for (const dep of (vesselConfig.dependencies || [])) {
|
|
@@ -63,7 +63,7 @@ export async function init({yes = false} = {}) {
|
|
|
63
63
|
onCancel() {
|
|
64
64
|
console.log('aborted');
|
|
65
65
|
process.exit(0);
|
|
66
|
-
}
|
|
66
|
+
},
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
// type
|
|
@@ -162,11 +162,11 @@ export async function init({yes = false} = {}) {
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
type ApplyInitOptions = {
|
|
165
|
-
type: 'project' | 'package';
|
|
166
|
-
config: Config;
|
|
167
|
-
setupWorkflow: boolean;
|
|
168
|
-
addTest: boolean;
|
|
169
|
-
copyrightOwner: string;
|
|
165
|
+
type : 'project' | 'package';
|
|
166
|
+
config : Config;
|
|
167
|
+
setupWorkflow : boolean;
|
|
168
|
+
addTest : boolean;
|
|
169
|
+
copyrightOwner : string;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
async function applyInit({type, config, setupWorkflow, addTest, copyrightOwner} : ApplyInitOptions) {
|
package/commands/install-all.ts
CHANGED
|
@@ -9,12 +9,12 @@ import {checkIntegrity} from '../integrity.js';
|
|
|
9
9
|
import {installLocal} from './install-local.js';
|
|
10
10
|
|
|
11
11
|
type InstallAllOptions = {
|
|
12
|
-
verbose?: boolean;
|
|
13
|
-
silent?: boolean;
|
|
14
|
-
lock?: 'check' | 'update' | 'ignore';
|
|
12
|
+
verbose ?: boolean;
|
|
13
|
+
silent ?: boolean;
|
|
14
|
+
lock ?: 'check' | 'update' | 'ignore';
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export async function installAll({verbose = false, silent = false, lock}: InstallAllOptions = {}) {
|
|
17
|
+
export async function installAll({verbose = false, silent = false, lock} : InstallAllOptions = {}) {
|
|
18
18
|
if (!checkConfigFile()) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
@@ -6,7 +6,7 @@ import {install} from './install.js';
|
|
|
6
6
|
|
|
7
7
|
// skip install and just find non-local dependencies to install
|
|
8
8
|
// pkgPath should be relative to the current root dir or absolute
|
|
9
|
-
export async function installLocal(pkg: string, pkgPath = '', {verbose = false, silent = false} = {}): Promise<Record<string, string> | false> {
|
|
9
|
+
export async function installLocal(pkg : string, pkgPath = '', {verbose = false, silent = false} = {}) : Promise<Record<string, string> | false> {
|
|
10
10
|
if (!checkConfigFile()) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
package/commands/install.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {addCache, copyCache, isCached} from '../cache.js';
|
|
|
11
11
|
import {downloadFile, getPackageFilesInfo} from '../api/downloadPackageFiles.js';
|
|
12
12
|
import {installLocal} from './install-local.js';
|
|
13
13
|
|
|
14
|
-
export async function install(pkg: string, version = '', {verbose = false, silent = false, dep = false} = {}): Promise<Record<string, string> | false> {
|
|
14
|
+
export async function install(pkg : string, version = '', {verbose = false, silent = false, dep = false} = {}) : Promise<Record<string, string> | false> {
|
|
15
15
|
if (!checkConfigFile()) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
@@ -65,7 +65,7 @@ export async function install(pkg: string, version = '', {verbose = false, silen
|
|
|
65
65
|
let filesData = new Map;
|
|
66
66
|
let storage = await storageActor(storageId);
|
|
67
67
|
|
|
68
|
-
await parallel(threads, fileIds, async (fileId: string) => {
|
|
68
|
+
await parallel(threads, fileIds, async (fileId : string) => {
|
|
69
69
|
let {path, data} = await downloadFile(storage, fileId);
|
|
70
70
|
filesData.set(path, data);
|
|
71
71
|
progress();
|
package/commands/outdated.ts
CHANGED
|
File without changes
|
package/commands/publish.ts
CHANGED
|
@@ -5,19 +5,19 @@ import logUpdate from 'log-update';
|
|
|
5
5
|
import {globbySync} from 'globby';
|
|
6
6
|
import {minimatch} from 'minimatch';
|
|
7
7
|
import prompts from 'prompts';
|
|
8
|
-
import {fromMarkdown} from 'mdast-util-from-markdown';
|
|
9
|
-
import {toMarkdown} from 'mdast-util-to-markdown';
|
|
10
8
|
|
|
11
9
|
import {checkConfigFile, getIdentity, getRootDir, progressBar, readConfig} from '../mops.js';
|
|
12
10
|
import {mainActor} from '../api/actors.js';
|
|
13
11
|
import {parallel} from '../parallel.js';
|
|
14
12
|
import {docs} from './docs.js';
|
|
15
|
-
import {DependencyV2, PackageConfigV2} from '../declarations/main/main.did.js';
|
|
13
|
+
import {Benchmarks, DependencyV2, PackageConfigV2} from '../declarations/main/main.did.js';
|
|
16
14
|
import {Dependency} from '../types.js';
|
|
17
15
|
import {testWithReporter} from './test/test.js';
|
|
18
16
|
import {SilentReporter} from './test/reporters/silent-reporter.js';
|
|
17
|
+
import {findChangelogEntry} from '../helpers/find-changelog-entry.js';
|
|
18
|
+
import {bench} from './bench.js';
|
|
19
19
|
|
|
20
|
-
export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
|
|
20
|
+
export async function publish(options : {docs ?: boolean, test ?: boolean, bench ?: boolean} = {}) {
|
|
21
21
|
if (!checkConfigFile()) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
@@ -160,16 +160,16 @@ export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
let toBackendDep = (dep: Dependency): DependencyV2 => {
|
|
163
|
+
let toBackendDep = (dep : Dependency) : DependencyV2 => {
|
|
164
164
|
return {
|
|
165
165
|
...dep,
|
|
166
166
|
version: dep.version || '',
|
|
167
|
-
repo: dep.repo || ''
|
|
167
|
+
repo: dep.repo || '',
|
|
168
168
|
};
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
// map fields
|
|
172
|
-
let backendPkgConfig: PackageConfigV2 = {
|
|
172
|
+
let backendPkgConfig : PackageConfigV2 = {
|
|
173
173
|
name: config.package.name,
|
|
174
174
|
version: config.package.version,
|
|
175
175
|
keywords: config.package.keywords || [],
|
|
@@ -258,6 +258,25 @@ export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
+
// bench
|
|
262
|
+
let benchmarks : Benchmarks = [];
|
|
263
|
+
if (options.bench) {
|
|
264
|
+
console.log('Running benchmarks...');
|
|
265
|
+
try {
|
|
266
|
+
benchmarks = await bench('', {
|
|
267
|
+
replica: config.toolchain?.['pocket-ic'] ? 'pocket-ic' : 'dfx',
|
|
268
|
+
gc: 'copying',
|
|
269
|
+
forceGc: true,
|
|
270
|
+
silent: true,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
catch (err) {
|
|
274
|
+
console.error(err);
|
|
275
|
+
console.log(chalk.red('Error: ') + 'benchmarks failed');
|
|
276
|
+
process.exit(1);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
261
280
|
// progress
|
|
262
281
|
let total = files.length + 2;
|
|
263
282
|
let step = 0;
|
|
@@ -286,13 +305,18 @@ export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
|
|
|
286
305
|
});
|
|
287
306
|
}
|
|
288
307
|
|
|
308
|
+
// upload benchmarks
|
|
309
|
+
if (options.bench) {
|
|
310
|
+
await actor.uploadBenchmarks(puiblishingId, benchmarks);
|
|
311
|
+
}
|
|
312
|
+
|
|
289
313
|
// upload changelog
|
|
290
314
|
if (changelog) {
|
|
291
315
|
await actor.uploadNotes(puiblishingId, changelog);
|
|
292
316
|
}
|
|
293
317
|
|
|
294
318
|
// upload files
|
|
295
|
-
await parallel(8, files, async (file: string) => {
|
|
319
|
+
await parallel(8, files, async (file : string) => {
|
|
296
320
|
progress();
|
|
297
321
|
|
|
298
322
|
let chunkSize = 1024 * 1024 + 512 * 1024; // 1.5mb
|
|
@@ -338,7 +362,7 @@ export async function publish(options: {docs?: boolean, test?: boolean} = {}) {
|
|
|
338
362
|
console.log(chalk.green('Published ') + `${config.package.name}@${config.package.version}`);
|
|
339
363
|
}
|
|
340
364
|
|
|
341
|
-
function parseChangelog(version: string): string {
|
|
365
|
+
function parseChangelog(version : string) : string {
|
|
342
366
|
let rootDir = getRootDir();
|
|
343
367
|
let changelogFile = '';
|
|
344
368
|
|
|
@@ -365,7 +389,7 @@ function parseChangelog(version: string): string {
|
|
|
365
389
|
return changelog || '';
|
|
366
390
|
}
|
|
367
391
|
|
|
368
|
-
async function fetchGitHubReleaseNotes(repo: string, version: string): Promise<string> {
|
|
392
|
+
async function fetchGitHubReleaseNotes(repo : string, version : string) : Promise<string> {
|
|
369
393
|
let repoPath = new URL(repo).pathname;
|
|
370
394
|
let res = await fetch(`https://api.github.com/repos${repoPath}/releases/tags/${version}`);
|
|
371
395
|
let release = await res.json();
|
|
@@ -381,29 +405,4 @@ async function fetchGitHubReleaseNotes(repo: string, version: string): Promise<s
|
|
|
381
405
|
}
|
|
382
406
|
|
|
383
407
|
return release.body;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function findChangelogEntry(changelog: string, version: string): string {
|
|
387
|
-
let tree = fromMarkdown(changelog);
|
|
388
|
-
let found = false;
|
|
389
|
-
let nodes = [];
|
|
390
|
-
|
|
391
|
-
for (let node of tree.children) {
|
|
392
|
-
if (found) {
|
|
393
|
-
if (node.type === 'heading') {
|
|
394
|
-
break;
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
nodes.push(node);
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
else if (node.type === 'heading' && toMarkdown(node).match(new RegExp(`\\b${version}\\b`))) {
|
|
401
|
-
found = true;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
return toMarkdown({
|
|
406
|
-
type: 'root',
|
|
407
|
-
children: nodes,
|
|
408
|
-
});
|
|
409
408
|
}
|
package/commands/remove.ts
CHANGED
|
@@ -6,19 +6,19 @@ import {Config, Dependency} from '../types.js';
|
|
|
6
6
|
import {checkIntegrity} from '../integrity.js';
|
|
7
7
|
|
|
8
8
|
type RemoveOptions = {
|
|
9
|
-
verbose?: boolean;
|
|
10
|
-
dev?: boolean;
|
|
11
|
-
dryRun?: boolean;
|
|
12
|
-
lock?: 'update' | 'ignore';
|
|
9
|
+
verbose ?: boolean;
|
|
10
|
+
dev ?: boolean;
|
|
11
|
+
dryRun ?: boolean;
|
|
12
|
+
lock ?: 'update' | 'ignore';
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
-
export async function remove(name: string, {dev = false, verbose = false, dryRun = false, lock}: RemoveOptions = {}) {
|
|
16
|
+
export async function remove(name : string, {dev = false, verbose = false, dryRun = false, lock} : RemoveOptions = {}) {
|
|
17
17
|
if (!checkConfigFile()) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function getTransitiveDependencies(config: Config, exceptPkgId: string) {
|
|
21
|
+
function getTransitiveDependencies(config : Config, exceptPkgId : string) {
|
|
22
22
|
let deps = Object.values(config.dependencies || {});
|
|
23
23
|
let devDeps = Object.values(config['dev-dependencies'] || {});
|
|
24
24
|
return [...deps, ...devDeps]
|
|
@@ -30,7 +30,7 @@ export async function remove(name: string, {dev = false, verbose = false, dryRun
|
|
|
30
30
|
}).flat();
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function getTransitiveDependenciesOf(name: string, version: string | undefined, repo?: string) {
|
|
33
|
+
function getTransitiveDependenciesOf(name : string, version : string | undefined, repo ?: string) {
|
|
34
34
|
let pkgDir = '';
|
|
35
35
|
if (repo) {
|
|
36
36
|
pkgDir = formatGithubDir(name, repo);
|
|
@@ -44,7 +44,7 @@ export async function remove(name: string, {dev = false, verbose = false, dryRun
|
|
|
44
44
|
return [];
|
|
45
45
|
}
|
|
46
46
|
let config = readConfig(configFile);
|
|
47
|
-
let deps: Dependency[] = Object.values(config.dependencies || {}).map((dep) => {
|
|
47
|
+
let deps : Dependency[] = Object.values(config.dependencies || {}).map((dep) => {
|
|
48
48
|
return [dep, ...getTransitiveDependenciesOf(dep.name, dep.version)];
|
|
49
49
|
}).flat();
|
|
50
50
|
return deps;
|
package/commands/search.ts
CHANGED
|
@@ -2,7 +2,7 @@ import asTable from 'as-table';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import {mainActor} from '../api/actors.js';
|
|
4
4
|
|
|
5
|
-
export async function search(text: string) {
|
|
5
|
+
export async function search(text : string) {
|
|
6
6
|
let actor = await mainActor();
|
|
7
7
|
let [packages, _pageCount] = await actor.search(text, [], []);
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ export async function search(text: string) {
|
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
let ellipsis = (text: string, max: number) => {
|
|
14
|
+
let ellipsis = (text : string, max : number) => {
|
|
15
15
|
if (text.length <= max) {
|
|
16
16
|
return text;
|
|
17
17
|
}
|