ic-mops 2.4.0 → 2.5.1
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/CHANGELOG.md +20 -0
- package/api/network.ts +12 -4
- package/bun.lock +1082 -78
- package/bundle/cli.tgz +0 -0
- package/commands/add.ts +4 -1
- package/commands/build.ts +7 -12
- package/commands/install/install-dep.ts +5 -3
- package/commands/publish.ts +8 -8
- package/commands/remove.ts +5 -2
- package/commands/sources.ts +3 -2
- package/commands/sync.ts +13 -16
- package/commands/test/test.ts +3 -3
- package/commands/update.ts +13 -7
- package/commands/watch/error-checker.ts +3 -8
- package/commands/watch/warning-checker.ts +3 -8
- package/dist/api/network.js +11 -4
- package/dist/commands/add.js +4 -1
- package/dist/commands/build.js +5 -10
- package/dist/commands/install/install-dep.js +3 -3
- package/dist/commands/publish.js +8 -8
- package/dist/commands/remove.js +5 -2
- package/dist/commands/sources.js +3 -2
- package/dist/commands/sync.js +9 -14
- package/dist/commands/test/test.js +3 -3
- package/dist/commands/update.js +9 -4
- package/dist/commands/watch/error-checker.js +3 -8
- package/dist/commands/watch/warning-checker.js +3 -8
- package/dist/environments/web/cli.js +9 -0
- package/dist/helpers/find-changelog-entry.js +1 -1
- package/dist/integrity.js +9 -3
- package/dist/mops.js +3 -0
- package/dist/package.json +3 -5
- package/dist/parallel.js +9 -1
- package/dist/resolve-packages.js +4 -4
- package/dist/tests/build.test.js +3 -1
- package/dist/tests/helpers.js +8 -1
- package/dist/vessel.d.ts +1 -1
- package/dist/vessel.js +3 -2
- package/environments/web/cli.ts +12 -0
- package/helpers/find-changelog-entry.ts +3 -1
- package/integrity.ts +12 -3
- package/mops.ts +7 -0
- package/package.json +5 -7
- package/parallel.ts +16 -5
- package/resolve-packages.ts +6 -4
- package/tests/build.test.ts +4 -1
- package/tests/helpers.ts +9 -1
- package/vessel.ts +5 -3
package/bundle/cli.tgz
CHANGED
|
Binary file
|
package/commands/add.ts
CHANGED
|
@@ -101,9 +101,12 @@ export async function add(
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
if (pkgDetails.repo) {
|
|
104
|
-
await installFromGithub(pkgDetails.name, pkgDetails.repo, {
|
|
104
|
+
let res = await installFromGithub(pkgDetails.name, pkgDetails.repo, {
|
|
105
105
|
verbose: verbose,
|
|
106
106
|
});
|
|
107
|
+
if (!res) {
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
107
110
|
} else if (!pkgDetails.path) {
|
|
108
111
|
let res = await installMopsDep(pkgDetails.name, pkgDetails.version, {
|
|
109
112
|
verbose: verbose,
|
package/commands/build.ts
CHANGED
|
@@ -24,7 +24,7 @@ export async function build(
|
|
|
24
24
|
canisterNames: string[] | undefined,
|
|
25
25
|
options: Partial<BuildOptions>,
|
|
26
26
|
): Promise<void> {
|
|
27
|
-
if (canisterNames?.length
|
|
27
|
+
if (canisterNames?.length === 0) {
|
|
28
28
|
cliError("No canisters specified to build");
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -41,16 +41,11 @@ export async function build(
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (canisterNames) {
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!(name in canisters)) {
|
|
50
|
-
cliError(
|
|
51
|
-
`Motoko canister '${name}' not found in mops.toml configuration`,
|
|
52
|
-
);
|
|
53
|
-
}
|
|
44
|
+
let invalidNames = canisterNames.filter((name) => !(name in canisters));
|
|
45
|
+
if (invalidNames.length) {
|
|
46
|
+
cliError(
|
|
47
|
+
`Motoko canister(s) not found in mops.toml configuration: ${invalidNames.join(", ")}`,
|
|
48
|
+
);
|
|
54
49
|
}
|
|
55
50
|
}
|
|
56
51
|
|
|
@@ -184,7 +179,7 @@ export async function build(
|
|
|
184
179
|
|
|
185
180
|
console.log(
|
|
186
181
|
chalk.green(
|
|
187
|
-
`\n✓ Built ${Object.keys(filteredCanisters).length} canister${Object.keys(filteredCanisters).length
|
|
182
|
+
`\n✓ Built ${Object.keys(filteredCanisters).length} canister${Object.keys(filteredCanisters).length === 1 ? "" : "s"} successfully`,
|
|
188
183
|
),
|
|
189
184
|
);
|
|
190
185
|
}
|
|
@@ -20,12 +20,11 @@ export async function installDep(
|
|
|
20
20
|
parentPkgPath?: string,
|
|
21
21
|
): Promise<boolean> {
|
|
22
22
|
if (dep.repo) {
|
|
23
|
-
|
|
23
|
+
return installFromGithub(dep.name, dep.repo, {
|
|
24
24
|
silent,
|
|
25
25
|
verbose,
|
|
26
26
|
ignoreTransitive,
|
|
27
27
|
});
|
|
28
|
-
return true;
|
|
29
28
|
} else if (dep.path) {
|
|
30
29
|
let depPath = dep.path;
|
|
31
30
|
parentPkgPath = parentPkgPath || getRootDir();
|
|
@@ -46,5 +45,8 @@ export async function installDep(
|
|
|
46
45
|
});
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
console.warn(
|
|
49
|
+
`Warning: dependency "${dep.name}" has no version, repo, or path`,
|
|
50
|
+
);
|
|
51
|
+
return false;
|
|
50
52
|
}
|
package/commands/publish.ts
CHANGED
|
@@ -398,11 +398,11 @@ export async function publish(
|
|
|
398
398
|
console.log(chalk.red("Error: ") + publishing.err);
|
|
399
399
|
process.exit(1);
|
|
400
400
|
}
|
|
401
|
-
let
|
|
401
|
+
let publishingId = publishing.ok;
|
|
402
402
|
|
|
403
403
|
// upload test stats
|
|
404
404
|
if (options.test) {
|
|
405
|
-
await actor.uploadTestStats(
|
|
405
|
+
await actor.uploadTestStats(publishingId, {
|
|
406
406
|
passed: BigInt(reporter.passed),
|
|
407
407
|
passedNames: reporter.passedNamesFlat,
|
|
408
408
|
});
|
|
@@ -410,17 +410,17 @@ export async function publish(
|
|
|
410
410
|
|
|
411
411
|
// upload benchmarks
|
|
412
412
|
if (options.bench) {
|
|
413
|
-
await actor.uploadBenchmarks(
|
|
413
|
+
await actor.uploadBenchmarks(publishingId, benchmarks);
|
|
414
414
|
}
|
|
415
415
|
|
|
416
416
|
// upload changelog
|
|
417
417
|
if (changelog) {
|
|
418
|
-
await actor.uploadNotes(
|
|
418
|
+
await actor.uploadNotes(publishingId, changelog);
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
// upload docs coverage
|
|
422
422
|
if (options.docs) {
|
|
423
|
-
await actor.uploadDocsCoverage(
|
|
423
|
+
await actor.uploadDocsCoverage(publishingId, docsCov);
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
// upload files
|
|
@@ -438,7 +438,7 @@ export async function publish(
|
|
|
438
438
|
}
|
|
439
439
|
|
|
440
440
|
let res = await actor.startFileUpload(
|
|
441
|
-
|
|
441
|
+
publishingId,
|
|
442
442
|
file,
|
|
443
443
|
BigInt(chunkCount),
|
|
444
444
|
firstChunk,
|
|
@@ -453,7 +453,7 @@ export async function publish(
|
|
|
453
453
|
let start = i * chunkSize;
|
|
454
454
|
let chunk = Array.from(content.slice(start, start + chunkSize));
|
|
455
455
|
let res = await actor.uploadFileChunk(
|
|
456
|
-
|
|
456
|
+
publishingId,
|
|
457
457
|
fileId,
|
|
458
458
|
BigInt(i),
|
|
459
459
|
chunk,
|
|
@@ -474,7 +474,7 @@ export async function publish(
|
|
|
474
474
|
progress();
|
|
475
475
|
logUpdate.done();
|
|
476
476
|
|
|
477
|
-
let res = await actor.finishPublish(
|
|
477
|
+
let res = await actor.finishPublish(publishingId);
|
|
478
478
|
if ("err" in res) {
|
|
479
479
|
console.log(chalk.red("Error: ") + res.err);
|
|
480
480
|
process.exit(1);
|
package/commands/remove.ts
CHANGED
|
@@ -65,7 +65,10 @@ export async function remove(
|
|
|
65
65
|
let config = readConfig(configFile);
|
|
66
66
|
let deps: Dependency[] = Object.values(config.dependencies || {})
|
|
67
67
|
.map((dep) => {
|
|
68
|
-
return [
|
|
68
|
+
return [
|
|
69
|
+
dep,
|
|
70
|
+
...getTransitiveDependenciesOf(dep.name, dep.version, dep.repo),
|
|
71
|
+
];
|
|
69
72
|
})
|
|
70
73
|
.flat();
|
|
71
74
|
return deps;
|
|
@@ -97,7 +100,7 @@ export async function remove(
|
|
|
97
100
|
// transitive deps of this package (including itself)
|
|
98
101
|
let transitiveDepsOfPackage = [
|
|
99
102
|
pkgDetails,
|
|
100
|
-
...getTransitiveDependenciesOf(name, version),
|
|
103
|
+
...getTransitiveDependenciesOf(name, version, pkgDetails.repo),
|
|
101
104
|
];
|
|
102
105
|
|
|
103
106
|
// remove local cache
|
package/commands/sources.ts
CHANGED
|
@@ -38,8 +38,9 @@ export async function sourcesArgs({
|
|
|
38
38
|
|
|
39
39
|
// append baseDir
|
|
40
40
|
let pkgBaseDir;
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
let resolvedMopsToml = path.resolve(cwd, pkgDir, "mops.toml");
|
|
42
|
+
if (fs.existsSync(resolvedMopsToml)) {
|
|
43
|
+
let config = readConfig(resolvedMopsToml);
|
|
43
44
|
pkgBaseDir = path.join(pkgDir, config.package?.baseDir || "src");
|
|
44
45
|
} else {
|
|
45
46
|
pkgBaseDir = path.join(pkgDir, "src");
|
package/commands/sync.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { remove } from "./remove.js";
|
|
|
8
8
|
import { checkIntegrity } from "../integrity.js";
|
|
9
9
|
import { getMocPath } from "../helpers/get-moc-path.js";
|
|
10
10
|
import { MOTOKO_IGNORE_PATTERNS } from "../constants.js";
|
|
11
|
+
import { getDepName } from "../helpers/get-dep-name.js";
|
|
11
12
|
|
|
12
13
|
type SyncOptions = {
|
|
13
14
|
lock?: "update" | "ignore";
|
|
@@ -80,26 +81,22 @@ async function getUsedPackages(): Promise<string[]> {
|
|
|
80
81
|
|
|
81
82
|
async function getMissingPackages(): Promise<string[]> {
|
|
82
83
|
let config = readConfig();
|
|
83
|
-
let
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return [...missing];
|
|
84
|
+
let allDepNames = new Set(
|
|
85
|
+
[
|
|
86
|
+
...Object.keys(config.dependencies || {}),
|
|
87
|
+
...Object.keys(config["dev-dependencies"] || {}),
|
|
88
|
+
].map((key) => getDepName(key)),
|
|
89
|
+
);
|
|
90
|
+
let used = await getUsedPackages();
|
|
91
|
+
return used.filter((pkg) => !allDepNames.has(pkg));
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
async function getUnusedPackages(): Promise<string[]> {
|
|
95
95
|
let config = readConfig();
|
|
96
|
-
let allDeps =
|
|
96
|
+
let allDeps = [
|
|
97
97
|
...Object.keys(config.dependencies || {}),
|
|
98
98
|
...Object.keys(config["dev-dependencies"] || {}),
|
|
99
|
-
]
|
|
100
|
-
let used = await getUsedPackages();
|
|
101
|
-
|
|
102
|
-
allDeps.delete(pkg);
|
|
103
|
-
}
|
|
104
|
-
return [...allDeps];
|
|
99
|
+
];
|
|
100
|
+
let used = new Set(await getUsedPackages());
|
|
101
|
+
return allDeps.filter((key) => !used.has(getDepName(key)));
|
|
105
102
|
}
|
package/commands/test/test.ts
CHANGED
|
@@ -12,7 +12,7 @@ import debounce from "debounce";
|
|
|
12
12
|
import { SemVer } from "semver";
|
|
13
13
|
import { ActorMethod } from "@icp-sdk/core/agent";
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { sourcesArgs } from "../sources.js";
|
|
16
16
|
import { getGlobalMocArgs, getRootDir, readConfig } from "../../mops.js";
|
|
17
17
|
import { parallel } from "../../parallel.js";
|
|
18
18
|
|
|
@@ -231,7 +231,7 @@ export async function testWithReporter(
|
|
|
231
231
|
reporter.addFiles(files);
|
|
232
232
|
|
|
233
233
|
let config = readConfig();
|
|
234
|
-
let sourcesArr = await
|
|
234
|
+
let sourcesArr = (await sourcesArgs()).flat();
|
|
235
235
|
let globalMocArgs = getGlobalMocArgs(config);
|
|
236
236
|
|
|
237
237
|
if (!mocPath) {
|
|
@@ -298,7 +298,7 @@ export async function testWithReporter(
|
|
|
298
298
|
let mocArgs = [
|
|
299
299
|
"--hide-warnings",
|
|
300
300
|
"--error-detail=2",
|
|
301
|
-
...sourcesArr
|
|
301
|
+
...sourcesArr,
|
|
302
302
|
...globalMocArgs,
|
|
303
303
|
file,
|
|
304
304
|
].filter((x) => x);
|
package/commands/update.ts
CHANGED
|
@@ -42,12 +42,18 @@ export async function update(pkg?: string, { lock }: UpdateOptions = {}) {
|
|
|
42
42
|
for (let dep of githubDeps) {
|
|
43
43
|
let { org, gitName, branch, commitHash } = parseGithubURL(dep.repo || "");
|
|
44
44
|
let dev = !!config["dev-dependencies"]?.[dep.name];
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
try {
|
|
46
|
+
let commit = await getGithubCommit(`${org}/${gitName}`, branch);
|
|
47
|
+
if (commit.sha !== commitHash) {
|
|
48
|
+
await add(
|
|
49
|
+
`https://github.com/${org}/${gitName}#${branch}@${commit.sha}`,
|
|
50
|
+
{ dev, lock },
|
|
51
|
+
dep.name,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
} catch (err: any) {
|
|
55
|
+
console.log(
|
|
56
|
+
chalk.red("Error: ") + `Failed to update ${dep.name}: ${err.message}`,
|
|
51
57
|
);
|
|
52
58
|
}
|
|
53
59
|
}
|
|
@@ -87,7 +93,7 @@ export async function update(pkg?: string, { lock }: UpdateOptions = {}) {
|
|
|
87
93
|
);
|
|
88
94
|
}) || dep[0];
|
|
89
95
|
|
|
90
|
-
await add(`${dep[0]}@${dep[2]}`, { dev }, asName);
|
|
96
|
+
await add(`${dep[0]}@${dep[2]}`, { dev, lock }, asName);
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
99
|
|
|
@@ -5,7 +5,7 @@ import chalk from "chalk";
|
|
|
5
5
|
|
|
6
6
|
import { getMocPath } from "../../helpers/get-moc-path.js";
|
|
7
7
|
import { getGlobalMocArgs, getRootDir, readConfig } from "../../mops.js";
|
|
8
|
-
import {
|
|
8
|
+
import { sourcesArgs } from "../sources.js";
|
|
9
9
|
import { parallel } from "../../parallel.js";
|
|
10
10
|
import { globMoFiles } from "./globMoFiles.js";
|
|
11
11
|
|
|
@@ -43,7 +43,7 @@ export class ErrorChecker {
|
|
|
43
43
|
|
|
44
44
|
let rootDir = getRootDir();
|
|
45
45
|
let mocPath = getMocPath();
|
|
46
|
-
let deps = await
|
|
46
|
+
let deps = (await sourcesArgs({ cwd: rootDir })).flat();
|
|
47
47
|
let globalMocArgs = getGlobalMocArgs(readConfig());
|
|
48
48
|
|
|
49
49
|
let paths = globMoFiles(rootDir);
|
|
@@ -55,12 +55,7 @@ export class ErrorChecker {
|
|
|
55
55
|
try {
|
|
56
56
|
await promisify(execFile)(
|
|
57
57
|
mocPath,
|
|
58
|
-
[
|
|
59
|
-
"--check",
|
|
60
|
-
...deps.flatMap((x) => x.split(" ")),
|
|
61
|
-
...globalMocArgs,
|
|
62
|
-
file,
|
|
63
|
-
],
|
|
58
|
+
["--check", ...deps, ...globalMocArgs, file],
|
|
64
59
|
{ cwd: rootDir },
|
|
65
60
|
);
|
|
66
61
|
} catch (error: any) {
|
|
@@ -5,7 +5,7 @@ import chalk from "chalk";
|
|
|
5
5
|
|
|
6
6
|
import { getMocPath } from "../../helpers/get-moc-path.js";
|
|
7
7
|
import { getGlobalMocArgs, getRootDir, readConfig } from "../../mops.js";
|
|
8
|
-
import {
|
|
8
|
+
import { sourcesArgs } from "../sources.js";
|
|
9
9
|
import { ErrorChecker } from "./error-checker.js";
|
|
10
10
|
import { parallel } from "../../parallel.js";
|
|
11
11
|
import { globMoFiles } from "./globMoFiles.js";
|
|
@@ -69,7 +69,7 @@ export class WarningChecker {
|
|
|
69
69
|
|
|
70
70
|
let rootDir = getRootDir();
|
|
71
71
|
let mocPath = getMocPath();
|
|
72
|
-
let deps = await
|
|
72
|
+
let deps = (await sourcesArgs({ cwd: rootDir })).flat();
|
|
73
73
|
let globalMocArgs = getGlobalMocArgs(readConfig());
|
|
74
74
|
let paths = globMoFiles(rootDir);
|
|
75
75
|
|
|
@@ -83,12 +83,7 @@ export class WarningChecker {
|
|
|
83
83
|
|
|
84
84
|
let { stderr } = await promisify(execFile)(
|
|
85
85
|
mocPath,
|
|
86
|
-
[
|
|
87
|
-
"--check",
|
|
88
|
-
...deps.flatMap((x) => x.split(" ")),
|
|
89
|
-
...globalMocArgs,
|
|
90
|
-
file,
|
|
91
|
-
],
|
|
86
|
+
["--check", ...deps, ...globalMocArgs, file],
|
|
92
87
|
{ cwd: rootDir, signal },
|
|
93
88
|
).catch((error) => {
|
|
94
89
|
if (error.code === "ABORT_ERR") {
|
package/dist/api/network.js
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
export function getNetwork() {
|
|
2
|
-
return globalThis.MOPS_NETWORK || "ic";
|
|
2
|
+
return process.env["MOPS_NETWORK"] || globalThis.MOPS_NETWORK || "ic";
|
|
3
3
|
}
|
|
4
4
|
export function getEndpoint(network) {
|
|
5
|
+
let endpoint;
|
|
5
6
|
if (network === "staging") {
|
|
6
|
-
|
|
7
|
+
endpoint = {
|
|
7
8
|
host: "https://icp-api.io",
|
|
8
9
|
canisterId: "2d2zu-vaaaa-aaaak-qb6pq-cai",
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
12
|
else if (network === "ic") {
|
|
12
|
-
|
|
13
|
+
endpoint = {
|
|
13
14
|
host: "https://icp-api.io",
|
|
14
15
|
canisterId: "oknww-riaaa-aaaam-qaf6a-cai",
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
else {
|
|
18
|
-
|
|
19
|
+
endpoint = {
|
|
19
20
|
host: "http://127.0.0.1:4943",
|
|
20
21
|
canisterId: "2d2zu-vaaaa-aaaak-qb6pq-cai",
|
|
21
22
|
};
|
|
22
23
|
}
|
|
24
|
+
const hostOverride = process.env["MOPS_REGISTRY_HOST"]?.trim();
|
|
25
|
+
const canisterOverride = process.env["MOPS_REGISTRY_CANISTER_ID"]?.trim();
|
|
26
|
+
return {
|
|
27
|
+
host: hostOverride || endpoint.host,
|
|
28
|
+
canisterId: canisterOverride || endpoint.canisterId,
|
|
29
|
+
};
|
|
23
30
|
}
|
package/dist/commands/add.js
CHANGED
|
@@ -77,9 +77,12 @@ export async function add(name, { verbose = false, dev = false, lock } = {}, asN
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
if (pkgDetails.repo) {
|
|
80
|
-
await installFromGithub(pkgDetails.name, pkgDetails.repo, {
|
|
80
|
+
let res = await installFromGithub(pkgDetails.name, pkgDetails.repo, {
|
|
81
81
|
verbose: verbose,
|
|
82
82
|
});
|
|
83
|
+
if (!res) {
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
83
86
|
}
|
|
84
87
|
else if (!pkgDetails.path) {
|
|
85
88
|
let res = await installMopsDep(pkgDetails.name, pkgDetails.version, {
|
package/dist/commands/build.js
CHANGED
|
@@ -12,7 +12,7 @@ import { sourcesArgs } from "./sources.js";
|
|
|
12
12
|
import { toolchain } from "./toolchain/index.js";
|
|
13
13
|
export const DEFAULT_BUILD_OUTPUT_DIR = ".mops/.build";
|
|
14
14
|
export async function build(canisterNames, options) {
|
|
15
|
-
if (canisterNames?.length
|
|
15
|
+
if (canisterNames?.length === 0) {
|
|
16
16
|
cliError("No canisters specified to build");
|
|
17
17
|
}
|
|
18
18
|
let config = readConfig();
|
|
@@ -26,14 +26,9 @@ export async function build(canisterNames, options) {
|
|
|
26
26
|
cliError(`No Motoko canisters found in mops.toml configuration`);
|
|
27
27
|
}
|
|
28
28
|
if (canisterNames) {
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
for (let name of canisterNames) {
|
|
34
|
-
if (!(name in canisters)) {
|
|
35
|
-
cliError(`Motoko canister '${name}' not found in mops.toml configuration`);
|
|
36
|
-
}
|
|
29
|
+
let invalidNames = canisterNames.filter((name) => !(name in canisters));
|
|
30
|
+
if (invalidNames.length) {
|
|
31
|
+
cliError(`Motoko canister(s) not found in mops.toml configuration: ${invalidNames.join(", ")}`);
|
|
37
32
|
}
|
|
38
33
|
}
|
|
39
34
|
if (!(await exists(outputDir))) {
|
|
@@ -131,7 +126,7 @@ export async function build(canisterNames, options) {
|
|
|
131
126
|
cliError(`Error while compiling canister ${canisterName}${err?.message ? `\n${err.message}` : ""}`);
|
|
132
127
|
}
|
|
133
128
|
}
|
|
134
|
-
console.log(chalk.green(`\n✓ Built ${Object.keys(filteredCanisters).length} canister${Object.keys(filteredCanisters).length
|
|
129
|
+
console.log(chalk.green(`\n✓ Built ${Object.keys(filteredCanisters).length} canister${Object.keys(filteredCanisters).length === 1 ? "" : "s"} successfully`));
|
|
135
130
|
}
|
|
136
131
|
const managedFlags = {
|
|
137
132
|
"-o": "use [build].outputDir in mops.toml or --output flag instead",
|
|
@@ -7,12 +7,11 @@ import { getRootDir } from "../../mops.js";
|
|
|
7
7
|
// returns false if failed
|
|
8
8
|
export async function installDep(dep, { verbose, silent, threads, ignoreTransitive } = {}, parentPkgPath) {
|
|
9
9
|
if (dep.repo) {
|
|
10
|
-
|
|
10
|
+
return installFromGithub(dep.name, dep.repo, {
|
|
11
11
|
silent,
|
|
12
12
|
verbose,
|
|
13
13
|
ignoreTransitive,
|
|
14
14
|
});
|
|
15
|
-
return true;
|
|
16
15
|
}
|
|
17
16
|
else if (dep.path) {
|
|
18
17
|
let depPath = dep.path;
|
|
@@ -34,5 +33,6 @@ export async function installDep(dep, { verbose, silent, threads, ignoreTransiti
|
|
|
34
33
|
ignoreTransitive,
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
|
-
|
|
36
|
+
console.warn(`Warning: dependency "${dep.name}" has no version, repo, or path`);
|
|
37
|
+
return false;
|
|
38
38
|
}
|
package/dist/commands/publish.js
CHANGED
|
@@ -316,25 +316,25 @@ export async function publish(options = {}) {
|
|
|
316
316
|
console.log(chalk.red("Error: ") + publishing.err);
|
|
317
317
|
process.exit(1);
|
|
318
318
|
}
|
|
319
|
-
let
|
|
319
|
+
let publishingId = publishing.ok;
|
|
320
320
|
// upload test stats
|
|
321
321
|
if (options.test) {
|
|
322
|
-
await actor.uploadTestStats(
|
|
322
|
+
await actor.uploadTestStats(publishingId, {
|
|
323
323
|
passed: BigInt(reporter.passed),
|
|
324
324
|
passedNames: reporter.passedNamesFlat,
|
|
325
325
|
});
|
|
326
326
|
}
|
|
327
327
|
// upload benchmarks
|
|
328
328
|
if (options.bench) {
|
|
329
|
-
await actor.uploadBenchmarks(
|
|
329
|
+
await actor.uploadBenchmarks(publishingId, benchmarks);
|
|
330
330
|
}
|
|
331
331
|
// upload changelog
|
|
332
332
|
if (changelog) {
|
|
333
|
-
await actor.uploadNotes(
|
|
333
|
+
await actor.uploadNotes(publishingId, changelog);
|
|
334
334
|
}
|
|
335
335
|
// upload docs coverage
|
|
336
336
|
if (options.docs) {
|
|
337
|
-
await actor.uploadDocsCoverage(
|
|
337
|
+
await actor.uploadDocsCoverage(publishingId, docsCov);
|
|
338
338
|
}
|
|
339
339
|
// upload files
|
|
340
340
|
await parallel(8, files, async (file) => {
|
|
@@ -347,7 +347,7 @@ export async function publish(options = {}) {
|
|
|
347
347
|
if (file === docsFile) {
|
|
348
348
|
file = path.basename(file);
|
|
349
349
|
}
|
|
350
|
-
let res = await actor.startFileUpload(
|
|
350
|
+
let res = await actor.startFileUpload(publishingId, file, BigInt(chunkCount), firstChunk);
|
|
351
351
|
if ("err" in res) {
|
|
352
352
|
console.log(chalk.red("Error: ") + res.err);
|
|
353
353
|
process.exit(1);
|
|
@@ -356,7 +356,7 @@ export async function publish(options = {}) {
|
|
|
356
356
|
for (let i = 1; i < chunkCount; i++) {
|
|
357
357
|
let start = i * chunkSize;
|
|
358
358
|
let chunk = Array.from(content.slice(start, start + chunkSize));
|
|
359
|
-
let res = await actor.uploadFileChunk(
|
|
359
|
+
let res = await actor.uploadFileChunk(publishingId, fileId, BigInt(i), chunk);
|
|
360
360
|
if ("err" in res) {
|
|
361
361
|
console.log(chalk.red("Error: ") + res.err);
|
|
362
362
|
process.exit(1);
|
|
@@ -370,7 +370,7 @@ export async function publish(options = {}) {
|
|
|
370
370
|
// finish
|
|
371
371
|
progress();
|
|
372
372
|
logUpdate.done();
|
|
373
|
-
let res = await actor.finishPublish(
|
|
373
|
+
let res = await actor.finishPublish(publishingId);
|
|
374
374
|
if ("err" in res) {
|
|
375
375
|
console.log(chalk.red("Error: ") + res.err);
|
|
376
376
|
process.exit(1);
|
package/dist/commands/remove.js
CHANGED
|
@@ -42,7 +42,10 @@ export async function remove(name, { dev = false, verbose = false, dryRun = fals
|
|
|
42
42
|
let config = readConfig(configFile);
|
|
43
43
|
let deps = Object.values(config.dependencies || {})
|
|
44
44
|
.map((dep) => {
|
|
45
|
-
return [
|
|
45
|
+
return [
|
|
46
|
+
dep,
|
|
47
|
+
...getTransitiveDependenciesOf(dep.name, dep.version, dep.repo),
|
|
48
|
+
];
|
|
46
49
|
})
|
|
47
50
|
.flat();
|
|
48
51
|
return deps;
|
|
@@ -65,7 +68,7 @@ export async function remove(name, { dev = false, verbose = false, dryRun = fals
|
|
|
65
68
|
// transitive deps of this package (including itself)
|
|
66
69
|
let transitiveDepsOfPackage = [
|
|
67
70
|
pkgDetails,
|
|
68
|
-
...getTransitiveDependenciesOf(name, version),
|
|
71
|
+
...getTransitiveDependenciesOf(name, version, pkgDetails.repo),
|
|
69
72
|
];
|
|
70
73
|
// remove local cache
|
|
71
74
|
for (let dep of transitiveDepsOfPackage) {
|
package/dist/commands/sources.js
CHANGED
|
@@ -27,8 +27,9 @@ export async function sourcesArgs({ conflicts = "ignore", cwd = process.cwd(), }
|
|
|
27
27
|
}
|
|
28
28
|
// append baseDir
|
|
29
29
|
let pkgBaseDir;
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
let resolvedMopsToml = path.resolve(cwd, pkgDir, "mops.toml");
|
|
31
|
+
if (fs.existsSync(resolvedMopsToml)) {
|
|
32
|
+
let config = readConfig(resolvedMopsToml);
|
|
32
33
|
pkgBaseDir = path.join(pkgDir, config.package?.baseDir || "src");
|
|
33
34
|
}
|
|
34
35
|
else {
|
package/dist/commands/sync.js
CHANGED
|
@@ -8,6 +8,7 @@ import { remove } from "./remove.js";
|
|
|
8
8
|
import { checkIntegrity } from "../integrity.js";
|
|
9
9
|
import { getMocPath } from "../helpers/get-moc-path.js";
|
|
10
10
|
import { MOTOKO_IGNORE_PATTERNS } from "../constants.js";
|
|
11
|
+
import { getDepName } from "../helpers/get-dep-name.js";
|
|
11
12
|
export async function sync({ lock } = {}) {
|
|
12
13
|
if (!checkConfigFile()) {
|
|
13
14
|
return;
|
|
@@ -58,25 +59,19 @@ async function getUsedPackages() {
|
|
|
58
59
|
}
|
|
59
60
|
async function getMissingPackages() {
|
|
60
61
|
let config = readConfig();
|
|
61
|
-
let
|
|
62
|
+
let allDepNames = new Set([
|
|
62
63
|
...Object.keys(config.dependencies || {}),
|
|
63
64
|
...Object.keys(config["dev-dependencies"] || {}),
|
|
64
|
-
];
|
|
65
|
-
let
|
|
66
|
-
|
|
67
|
-
missing.delete(pkg);
|
|
68
|
-
}
|
|
69
|
-
return [...missing];
|
|
65
|
+
].map((key) => getDepName(key)));
|
|
66
|
+
let used = await getUsedPackages();
|
|
67
|
+
return used.filter((pkg) => !allDepNames.has(pkg));
|
|
70
68
|
}
|
|
71
69
|
async function getUnusedPackages() {
|
|
72
70
|
let config = readConfig();
|
|
73
|
-
let allDeps =
|
|
71
|
+
let allDeps = [
|
|
74
72
|
...Object.keys(config.dependencies || {}),
|
|
75
73
|
...Object.keys(config["dev-dependencies"] || {}),
|
|
76
|
-
]
|
|
77
|
-
let used = await getUsedPackages();
|
|
78
|
-
|
|
79
|
-
allDeps.delete(pkg);
|
|
80
|
-
}
|
|
81
|
-
return [...allDeps];
|
|
74
|
+
];
|
|
75
|
+
let used = new Set(await getUsedPackages());
|
|
76
|
+
return allDeps.filter((key) => !used.has(getDepName(key)));
|
|
82
77
|
}
|
|
@@ -9,7 +9,7 @@ import { globSync } from "glob";
|
|
|
9
9
|
import chokidar from "chokidar";
|
|
10
10
|
import debounce from "debounce";
|
|
11
11
|
import { SemVer } from "semver";
|
|
12
|
-
import {
|
|
12
|
+
import { sourcesArgs } from "../sources.js";
|
|
13
13
|
import { getGlobalMocArgs, getRootDir, readConfig } from "../../mops.js";
|
|
14
14
|
import { parallel } from "../../parallel.js";
|
|
15
15
|
import { MMF1 } from "./mmf1.js";
|
|
@@ -151,7 +151,7 @@ export async function testWithReporter(reporterName, filter = "", defaultMode =
|
|
|
151
151
|
}
|
|
152
152
|
reporter.addFiles(files);
|
|
153
153
|
let config = readConfig();
|
|
154
|
-
let sourcesArr = await
|
|
154
|
+
let sourcesArr = (await sourcesArgs()).flat();
|
|
155
155
|
let globalMocArgs = getGlobalMocArgs(config);
|
|
156
156
|
if (!mocPath) {
|
|
157
157
|
mocPath = await toolchain.bin("moc", { fallback: true });
|
|
@@ -197,7 +197,7 @@ export async function testWithReporter(reporterName, filter = "", defaultMode =
|
|
|
197
197
|
let mocArgs = [
|
|
198
198
|
"--hide-warnings",
|
|
199
199
|
"--error-detail=2",
|
|
200
|
-
...sourcesArr
|
|
200
|
+
...sourcesArr,
|
|
201
201
|
...globalMocArgs,
|
|
202
202
|
file,
|
|
203
203
|
].filter((x) => x);
|
package/dist/commands/update.js
CHANGED
|
@@ -25,9 +25,14 @@ export async function update(pkg, { lock } = {}) {
|
|
|
25
25
|
for (let dep of githubDeps) {
|
|
26
26
|
let { org, gitName, branch, commitHash } = parseGithubURL(dep.repo || "");
|
|
27
27
|
let dev = !!config["dev-dependencies"]?.[dep.name];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
try {
|
|
29
|
+
let commit = await getGithubCommit(`${org}/${gitName}`, branch);
|
|
30
|
+
if (commit.sha !== commitHash) {
|
|
31
|
+
await add(`https://github.com/${org}/${gitName}#${branch}@${commit.sha}`, { dev, lock }, dep.name);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
console.log(chalk.red("Error: ") + `Failed to update ${dep.name}: ${err.message}`);
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
// update mops packages
|
|
@@ -58,7 +63,7 @@ export async function update(pkg, { lock } = {}) {
|
|
|
58
63
|
return (getDepName(d) === dep[0] &&
|
|
59
64
|
(!pinnedVersion || dep[1].startsWith(pinnedVersion)));
|
|
60
65
|
}) || dep[0];
|
|
61
|
-
await add(`${dep[0]}@${dep[2]}`, { dev }, asName);
|
|
66
|
+
await add(`${dep[0]}@${dep[2]}`, { dev, lock }, asName);
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
69
|
await checkIntegrity(lock);
|