ic-mops 2.13.1 → 2.14.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/CHANGELOG.md +25 -0
- package/bun.lock +24 -12
- package/bundle/cli.tgz +0 -0
- package/cache.ts +101 -20
- package/cli.ts +40 -14
- package/commands/available-updates.ts +4 -2
- package/commands/bench.ts +3 -0
- package/commands/check-stable.ts +27 -23
- package/commands/check.ts +11 -1
- package/commands/init.ts +15 -2
- package/commands/install/install-mops-dep.ts +14 -9
- package/commands/install/sync-local-cache.ts +7 -1
- package/commands/lint.ts +11 -0
- package/commands/outdated.ts +5 -2
- package/commands/publish.ts +0 -1
- package/commands/test/test.ts +14 -0
- package/commands/update.ts +3 -2
- package/commands/watch/tester.ts +5 -1
- package/dist/cache.d.ts +3 -0
- package/dist/cache.js +98 -18
- package/dist/cli.js +16 -12
- package/dist/commands/available-updates.d.ts +1 -1
- package/dist/commands/available-updates.js +4 -1
- package/dist/commands/bench.js +2 -0
- package/dist/commands/check-stable.d.ts +0 -1
- package/dist/commands/check-stable.js +21 -18
- package/dist/commands/check.js +7 -1
- package/dist/commands/init.js +9 -2
- package/dist/commands/install/install-mops-dep.js +12 -9
- package/dist/commands/install/sync-local-cache.js +2 -1
- package/dist/commands/lint.js +7 -0
- package/dist/commands/outdated.d.ts +2 -1
- package/dist/commands/outdated.js +2 -2
- package/dist/commands/publish.js +0 -1
- package/dist/commands/test/test.d.ts +1 -1
- package/dist/commands/test/test.js +10 -5
- package/dist/commands/update.d.ts +2 -1
- package/dist/commands/update.js +2 -2
- package/dist/commands/watch/tester.js +4 -1
- package/dist/helpers/autofix-motoko.d.ts +1 -1
- package/dist/helpers/autofix-motoko.js +3 -0
- package/dist/helpers/deprecate-dfx-replica.d.ts +2 -0
- package/dist/helpers/deprecate-dfx-replica.js +20 -0
- package/dist/helpers/fix-lock.d.ts +1 -0
- package/dist/helpers/fix-lock.js +93 -0
- package/dist/helpers/migrations.js +7 -5
- package/dist/integrity.d.ts +2 -2
- package/dist/integrity.js +22 -6
- package/dist/mops.js +1 -1
- package/dist/package.json +3 -3
- package/dist/tests/check-fix.test.js +40 -0
- package/dist/tests/check-stable.test.js +17 -0
- package/dist/tests/check.test.js +4 -3
- package/dist/tests/cli.test.js +136 -1
- package/dist/tests/helpers.js +5 -1
- package/dist/tests/migrate.test.js +2 -2
- package/dist/types.d.ts +1 -0
- package/dist/vessel.js +21 -13
- package/dist/wasm/pkg/nodejs/package.json +1 -1
- package/dist/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/web/package.json +1 -1
- package/dist/wasm/pkg/web/wasm_bg.wasm +0 -0
- package/helpers/autofix-motoko.ts +4 -1
- package/helpers/deprecate-dfx-replica.ts +32 -0
- package/helpers/fix-lock.ts +101 -0
- package/helpers/migrations.ts +7 -4
- package/integrity.ts +30 -9
- package/mops.ts +1 -1
- package/package.json +3 -3
- package/tests/__snapshots__/migrate.test.ts.snap +1 -2
- package/tests/check-fix.test.ts +46 -0
- package/tests/check-stable/migrations-chain/deployed.most +14 -0
- package/tests/check-stable/migrations-chain/migrations/20250101_000000_Init.mo +8 -0
- package/tests/check-stable/migrations-chain/migrations/20250201_000000_AddField.mo +9 -0
- package/tests/check-stable/migrations-chain/migrations/20250301_000000_AddD.mo +10 -0
- package/tests/check-stable/migrations-chain/migrations/20250401_000000_AddE.mo +11 -0
- package/tests/check-stable/migrations-chain/mops.toml +15 -0
- package/tests/check-stable/migrations-chain/src/main.mo +13 -0
- package/tests/check-stable.test.ts +20 -0
- package/tests/check.test.ts +4 -3
- package/tests/cli.test.ts +180 -1
- package/tests/helpers.ts +5 -1
- package/tests/install/update-bound-patch/mops.toml +2 -0
- package/tests/migrate.test.ts +2 -2
- package/types.ts +1 -0
- package/vessel.ts +31 -14
- package/wasm/pkg/nodejs/package.json +1 -1
- package/wasm/pkg/nodejs/wasm_bg.wasm +0 -0
- package/wasm/pkg/web/package.json +1 -1
- package/wasm/pkg/web/wasm_bg.wasm +0 -0
package/vessel.ts
CHANGED
|
@@ -2,20 +2,28 @@ import process from "node:process";
|
|
|
2
2
|
import {
|
|
3
3
|
existsSync,
|
|
4
4
|
mkdirSync,
|
|
5
|
+
mkdtempSync,
|
|
6
|
+
rmSync,
|
|
5
7
|
createWriteStream,
|
|
6
8
|
readFileSync,
|
|
7
9
|
writeFileSync,
|
|
8
10
|
} from "node:fs";
|
|
9
11
|
import path from "node:path";
|
|
10
12
|
import { pipeline } from "node:stream";
|
|
11
|
-
import { deleteSync } from "del";
|
|
12
13
|
import { execaCommand } from "execa";
|
|
13
14
|
import chalk from "chalk";
|
|
14
15
|
import { createLogUpdate } from "log-update";
|
|
15
16
|
import got from "got";
|
|
16
17
|
import decompress from "decompress";
|
|
17
|
-
import { parseGithubURL, progressBar } from "./mops.js";
|
|
18
|
-
import {
|
|
18
|
+
import { getRootDir, parseGithubURL, progressBar } from "./mops.js";
|
|
19
|
+
import {
|
|
20
|
+
commitStagingDir,
|
|
21
|
+
createStagingDir,
|
|
22
|
+
getDepCacheDir,
|
|
23
|
+
getGithubDepCacheName,
|
|
24
|
+
isDepCached,
|
|
25
|
+
sweepStaleStagingDirs,
|
|
26
|
+
} from "./cache.js";
|
|
19
27
|
|
|
20
28
|
const dhallFileToJson = async (filePath: string, silent: boolean) => {
|
|
21
29
|
if (existsSync(filePath)) {
|
|
@@ -130,18 +138,23 @@ export const downloadFromGithub = async (
|
|
|
130
138
|
|
|
131
139
|
// Prevent `onError` being called twice.
|
|
132
140
|
readStream.off("error", reject);
|
|
133
|
-
|
|
141
|
+
|
|
142
|
+
// Per-invocation download dir (was a shared `.mops/_tmp/` clobbered
|
|
143
|
+
// by concurrent github installs). `.staging-` prefix lets the sweeper
|
|
144
|
+
// pick up leftovers from a crashed download.
|
|
145
|
+
const parentTmp = path.resolve(getRootDir(), ".mops");
|
|
146
|
+
mkdirSync(parentTmp, { recursive: true });
|
|
147
|
+
const tmpDir = mkdtempSync(path.join(parentTmp, ".staging-github-dl-"));
|
|
134
148
|
const tmpFile = path.resolve(
|
|
135
149
|
tmpDir,
|
|
136
150
|
`${gitName}@${(commitHash || branch).replaceAll("/", "___")}.zip`,
|
|
137
151
|
);
|
|
152
|
+
const cleanup = () => rmSync(tmpDir, { recursive: true, force: true });
|
|
138
153
|
|
|
139
154
|
try {
|
|
140
|
-
mkdirSync(tmpDir, { recursive: true });
|
|
141
|
-
|
|
142
155
|
pipeline(readStream, createWriteStream(tmpFile), (err) => {
|
|
143
156
|
if (err) {
|
|
144
|
-
|
|
157
|
+
cleanup();
|
|
145
158
|
reject(err);
|
|
146
159
|
} else {
|
|
147
160
|
let options = {
|
|
@@ -153,17 +166,17 @@ export const downloadFromGithub = async (
|
|
|
153
166
|
};
|
|
154
167
|
decompress(tmpFile, dest, options)
|
|
155
168
|
.then((unzippedFiles) => {
|
|
156
|
-
|
|
169
|
+
cleanup();
|
|
157
170
|
resolve(unzippedFiles);
|
|
158
171
|
})
|
|
159
172
|
.catch((err) => {
|
|
160
|
-
|
|
173
|
+
cleanup();
|
|
161
174
|
reject(err);
|
|
162
175
|
});
|
|
163
176
|
}
|
|
164
177
|
});
|
|
165
178
|
} catch (err) {
|
|
166
|
-
|
|
179
|
+
cleanup();
|
|
167
180
|
reject(err);
|
|
168
181
|
}
|
|
169
182
|
});
|
|
@@ -182,6 +195,8 @@ export const installFromGithub = async (
|
|
|
182
195
|
ignoreTransitive = false,
|
|
183
196
|
} = {},
|
|
184
197
|
): Promise<boolean> => {
|
|
198
|
+
sweepStaleStagingDirs();
|
|
199
|
+
|
|
185
200
|
let cacheName = getGithubDepCacheName(name, repo);
|
|
186
201
|
let cacheDir = getDepCacheDir(cacheName);
|
|
187
202
|
|
|
@@ -199,12 +214,14 @@ export const installFromGithub = async (
|
|
|
199
214
|
|
|
200
215
|
progress(0, 1024 * 500);
|
|
201
216
|
|
|
202
|
-
|
|
203
|
-
|
|
217
|
+
// Stage download in a sibling dir; previously `mkdirSync(cacheDir)`
|
|
218
|
+
// before download made empty dirs look cached to peers.
|
|
219
|
+
let stagingDir = createStagingDir(cacheDir);
|
|
204
220
|
try {
|
|
205
|
-
await downloadFromGithub(repo,
|
|
221
|
+
await downloadFromGithub(repo, stagingDir, progress);
|
|
222
|
+
commitStagingDir(stagingDir, cacheDir);
|
|
206
223
|
} catch (err) {
|
|
207
|
-
|
|
224
|
+
rmSync(stagingDir, { recursive: true, force: true });
|
|
208
225
|
return false;
|
|
209
226
|
}
|
|
210
227
|
}
|
|
Binary file
|
|
Binary file
|