ic-mops 0.45.4-pre.0 → 1.0.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 +19 -1
- package/README.md +1 -1
- package/api/actors.ts +1 -1
- package/bundle/cli.tgz +0 -0
- package/cache.ts +15 -10
- package/cli.ts +27 -27
- package/commands/add.ts +4 -0
- package/commands/bench/bench-canister.mo +34 -8
- package/commands/bench-replica.ts +11 -6
- package/commands/bench.ts +29 -3
- package/commands/publish.ts +1 -1
- package/commands/replica.ts +239 -0
- package/commands/sources.ts +2 -3
- package/commands/test/mmf1.ts +10 -6
- package/commands/test/reporters/compact-reporter.ts +2 -1
- package/commands/test/reporters/files-reporter.ts +3 -2
- package/commands/test/reporters/reporter.ts +2 -1
- package/commands/test/reporters/silent-reporter.ts +2 -1
- package/commands/test/reporters/verbose-reporter.ts +14 -4
- package/commands/test/test.ts +214 -81
- package/commands/user.ts +71 -1
- package/declarations/bench/bench.did +6 -2
- package/declarations/bench/bench.did.d.ts +6 -2
- package/declarations/bench/bench.did.js +6 -2
- package/dist/cache.js +14 -10
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +23 -27
- package/dist/commands/add.js +3 -0
- package/dist/commands/bench/bench-canister.mo +34 -8
- package/dist/commands/bench-replica.d.ts +2 -1
- package/dist/commands/bench-replica.js +10 -6
- package/dist/commands/bench.js +27 -3
- package/dist/commands/publish.js +1 -1
- package/dist/commands/replica.d.ts +59 -0
- package/dist/commands/replica.js +195 -0
- package/dist/commands/sources.d.ts +2 -2
- package/dist/commands/sources.js +2 -3
- package/dist/commands/test/mmf1.d.ts +2 -2
- package/dist/commands/test/mmf1.js +9 -5
- package/dist/commands/test/reporters/compact-reporter.d.ts +2 -1
- package/dist/commands/test/reporters/compact-reporter.js +1 -1
- package/dist/commands/test/reporters/files-reporter.d.ts +2 -1
- package/dist/commands/test/reporters/files-reporter.js +2 -2
- package/dist/commands/test/reporters/reporter.d.ts +2 -1
- package/dist/commands/test/reporters/silent-reporter.d.ts +2 -1
- package/dist/commands/test/reporters/silent-reporter.js +1 -1
- package/dist/commands/test/reporters/verbose-reporter.d.ts +3 -1
- package/dist/commands/test/reporters/verbose-reporter.js +12 -4
- package/dist/commands/test/test.d.ts +10 -8
- package/dist/commands/test/test.js +171 -78
- package/dist/commands/user.d.ts +6 -0
- package/dist/commands/user.js +59 -1
- package/dist/declarations/bench/bench.did +6 -2
- package/dist/declarations/bench/bench.did.d.ts +6 -2
- package/dist/declarations/bench/bench.did.js +6 -2
- package/dist/mops.d.ts +1 -1
- package/dist/mops.js +5 -29
- package/dist/package.json +20 -21
- package/dist/release-cli.js +5 -2
- package/dist/resolve-packages.d.ts +2 -2
- package/dist/resolve-packages.js +29 -7
- package/dist/types.d.ts +1 -0
- package/dist/vessel.js +1 -1
- package/mops.ts +5 -32
- package/package.json +24 -24
- package/release-cli.ts +7 -2
- package/resolve-packages.ts +39 -8
- package/types.ts +3 -1
- package/vessel.ts +1 -1
- package/DEVELOPMENT.md +0 -25
- package/commands/import-identity.ts +0 -62
- package/commands/whoami.ts +0 -12
- package/dist/commands/import-identity.d.ts +0 -5
- package/dist/commands/import-identity.js +0 -51
- package/dist/commands/whoami.d.ts +0 -1
- package/dist/commands/whoami.js +0 -11
package/dist/release-cli.js
CHANGED
|
@@ -8,8 +8,9 @@ import { sha256 } from '@noble/hashes/sha256';
|
|
|
8
8
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
9
9
|
import { findChangelogEntry } from './helpers/find-changelog-entry.js';
|
|
10
10
|
let __dirname = new URL('.', import.meta.url).pathname;
|
|
11
|
-
|
|
12
|
-
execSync('
|
|
11
|
+
// build using Docker
|
|
12
|
+
execSync('./build.sh', { stdio: 'inherit', cwd: __dirname });
|
|
13
|
+
let commitHash = process.env.COMMIT_HASH || execSync('git rev-parse HEAD').toString().trim();
|
|
13
14
|
let version = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf8')).version;
|
|
14
15
|
let major = semver.parse(version)?.major;
|
|
15
16
|
let tag = semver.parse(version)?.prerelease[0] || 'latest';
|
|
@@ -17,6 +18,7 @@ let releaseNotes = findChangelogEntry(fs.readFileSync(path.resolve(__dirname, 'C
|
|
|
17
18
|
let data = fs.readFileSync(path.resolve(__dirname, 'bundle/cli.tgz'));
|
|
18
19
|
let hash = bytesToHex(sha256(data));
|
|
19
20
|
let size = data.byteLength;
|
|
21
|
+
console.log(`Commit hash of release: ${commitHash}`);
|
|
20
22
|
fs.cpSync(path.resolve(__dirname, 'bundle/cli.tgz'), path.resolve(__dirname, `../cli-releases/versions/${version}.tgz`), { force: false, errorOnExist: true });
|
|
21
23
|
fs.cpSync(path.resolve(__dirname, `../cli-releases/versions/${version}.tgz`), path.resolve(__dirname, `../cli-releases/versions/${tag}.tgz`), { force: true, errorOnExist: false, recursive: true });
|
|
22
24
|
fs.cpSync(path.resolve(__dirname, `../cli-releases/versions/${version}.tgz`), path.resolve(__dirname, `../cli-releases/versions/${major}.tgz`), { force: true, errorOnExist: false, recursive: true });
|
|
@@ -31,6 +33,7 @@ releases.versions[version] = {
|
|
|
31
33
|
time: new Date().getTime(),
|
|
32
34
|
size,
|
|
33
35
|
relseaseNotes: releaseNotes,
|
|
36
|
+
commitHash: commitHash,
|
|
34
37
|
url: `https://cli.mops.one/versions/${version}.tgz`,
|
|
35
38
|
hash,
|
|
36
39
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function resolvePackages({
|
|
2
|
-
|
|
1
|
+
export declare function resolvePackages({ conflicts }?: {
|
|
2
|
+
conflicts?: "ignore" | "error" | "warning" | undefined;
|
|
3
3
|
}): Promise<Record<string, string>>;
|
package/dist/resolve-packages.js
CHANGED
|
@@ -4,7 +4,8 @@ import chalk from 'chalk';
|
|
|
4
4
|
import { checkConfigFile, getRootDir, parseGithubURL, readConfig } from './mops.js';
|
|
5
5
|
import { readVesselConfig } from './vessel.js';
|
|
6
6
|
import { getDepCacheDir, getDepCacheName } from './cache.js';
|
|
7
|
-
|
|
7
|
+
import { getPackageId } from './helpers/get-package-id.js';
|
|
8
|
+
export async function resolvePackages({ conflicts = 'ignore' } = {}) {
|
|
8
9
|
if (!checkConfigFile()) {
|
|
9
10
|
return {};
|
|
10
11
|
}
|
|
@@ -79,30 +80,51 @@ export async function resolvePackages({ verbose = false } = {}) {
|
|
|
79
80
|
}
|
|
80
81
|
// collect nested deps
|
|
81
82
|
if (nestedConfig) {
|
|
82
|
-
await collectDeps(nestedConfig, localNestedDir);
|
|
83
|
+
await collectDeps(nestedConfig, localNestedDir, false);
|
|
83
84
|
}
|
|
84
85
|
if (!versions[name]) {
|
|
85
86
|
versions[name] = [];
|
|
86
87
|
}
|
|
88
|
+
let parentPkgId = isRoot ? '<root>' : '';
|
|
89
|
+
if ('package' in config) {
|
|
90
|
+
parentPkgId = getPackageId(config.package?.name || '', config.package?.version || '');
|
|
91
|
+
}
|
|
87
92
|
if (repo) {
|
|
88
93
|
const { branch } = parseGithubURL(repo);
|
|
89
|
-
versions[name]?.push(
|
|
94
|
+
versions[name]?.push({
|
|
95
|
+
version: branch,
|
|
96
|
+
dependencyOf: parentPkgId,
|
|
97
|
+
isMopsPackage: false,
|
|
98
|
+
});
|
|
90
99
|
}
|
|
91
100
|
else if (version) {
|
|
92
|
-
versions[name]?.push(
|
|
101
|
+
versions[name]?.push({
|
|
102
|
+
version: version,
|
|
103
|
+
dependencyOf: parentPkgId,
|
|
104
|
+
isMopsPackage: true,
|
|
105
|
+
});
|
|
93
106
|
}
|
|
94
107
|
}
|
|
95
108
|
};
|
|
96
109
|
let config = readConfig();
|
|
97
110
|
await collectDeps(config, rootDir, true);
|
|
98
111
|
// show conflicts
|
|
99
|
-
|
|
112
|
+
let hasConflicts = false;
|
|
113
|
+
if (conflicts !== 'ignore') {
|
|
100
114
|
for (let [dep, vers] of Object.entries(versions)) {
|
|
101
|
-
|
|
102
|
-
|
|
115
|
+
let majors = new Set(vers.filter(x => x.isMopsPackage).map(x => x.version.split('.')[0]));
|
|
116
|
+
if (majors.size > 1) {
|
|
117
|
+
console.error(chalk.reset('') + chalk.redBright(conflicts === 'error' ? 'Error!' : 'Warning!'), `Conflicting versions of dependency "${dep}"`);
|
|
118
|
+
for (let { version, dependencyOf } of vers.reverse()) {
|
|
119
|
+
console.error(chalk.reset(' ') + `${dep} ${chalk.bold.red(version.split('.')[0])}.${version.split('.').slice(1).join('.')} is dependency of ${chalk.bold(dependencyOf)}`);
|
|
120
|
+
}
|
|
121
|
+
hasConflicts = true;
|
|
103
122
|
}
|
|
104
123
|
}
|
|
105
124
|
}
|
|
125
|
+
if (conflicts === 'error' && hasConflicts) {
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
106
128
|
return Object.fromEntries(Object.entries(packages).map(([name, pkg]) => {
|
|
107
129
|
let version;
|
|
108
130
|
if (pkg.path) {
|
package/dist/types.d.ts
CHANGED
package/dist/vessel.js
CHANGED
|
@@ -82,7 +82,7 @@ export const downloadFromGithub = async (repo, dest, onProgress) => {
|
|
|
82
82
|
// Prevent `onError` being called twice.
|
|
83
83
|
readStream.off('error', reject);
|
|
84
84
|
const tmpDir = path.resolve(process.cwd(), '.mops/_tmp/');
|
|
85
|
-
const tmpFile = path.resolve(tmpDir, `${gitName}@${commitHash || branch}.zip`);
|
|
85
|
+
const tmpFile = path.resolve(tmpDir, `${gitName}@${(commitHash || branch).replaceAll('/', '___')}.zip`);
|
|
86
86
|
try {
|
|
87
87
|
mkdirSync(tmpDir, { recursive: true });
|
|
88
88
|
pipeline(readStream, createWriteStream(tmpFile), (err) => {
|
package/mops.ts
CHANGED
|
@@ -5,7 +5,6 @@ import {Identity} from '@dfinity/agent';
|
|
|
5
5
|
import TOML from '@iarna/toml';
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
import prompts from 'prompts';
|
|
8
|
-
import ncp from 'ncp';
|
|
9
8
|
import fetch from 'node-fetch';
|
|
10
9
|
|
|
11
10
|
import {decodeFile} from './pem.js';
|
|
@@ -47,35 +46,6 @@ if (process.env.XDG_CACHE_HOME) {
|
|
|
47
46
|
globalCacheDir = path.join(process.env.XDG_CACHE_HOME, 'mops');
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
// temp: move old config to new location
|
|
51
|
-
let oldGlobalConfigDir = path.resolve(process.env.HOME || process.env.APPDATA || '/', 'mops');
|
|
52
|
-
if (fs.existsSync(oldGlobalConfigDir) && !fs.existsSync(globalConfigDir)) {
|
|
53
|
-
fs.mkdirSync(globalConfigDir, {recursive: true});
|
|
54
|
-
if (fs.existsSync(path.join(oldGlobalConfigDir, 'identity.pem'))) {
|
|
55
|
-
fs.copyFileSync(path.join(oldGlobalConfigDir, 'identity.pem'), path.join(globalConfigDir, 'identity.pem'));
|
|
56
|
-
}
|
|
57
|
-
if (fs.existsSync(path.join(oldGlobalConfigDir, 'identity.pem.encrypted'))) {
|
|
58
|
-
fs.copyFileSync(path.join(oldGlobalConfigDir, 'identity.pem.encrypted'), path.join(globalConfigDir, 'identity.pem.encrypted'));
|
|
59
|
-
}
|
|
60
|
-
console.log('Moved config to ' + chalk.green(globalConfigDir));
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// temp: move old cache to new location
|
|
64
|
-
if (fs.existsSync(oldGlobalConfigDir) && !fs.existsSync(globalCacheDir)) {
|
|
65
|
-
fs.mkdirSync(globalCacheDir, {recursive: true});
|
|
66
|
-
ncp.ncp(path.join(oldGlobalConfigDir, 'packages'), path.join(globalCacheDir, 'packages'), {
|
|
67
|
-
stopOnErr: true,
|
|
68
|
-
clobber: false,
|
|
69
|
-
}, (err) => {
|
|
70
|
-
if (err) {
|
|
71
|
-
console.log('Error moving config: ', err);
|
|
72
|
-
fs.rmSync(globalCacheDir, {recursive: true, force: true});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
console.log('Moved cache to ' + chalk.green(globalCacheDir));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
49
|
export function getNetworkFile() : string | URL {
|
|
80
50
|
let networkFile : string | URL = '';
|
|
81
51
|
try {
|
|
@@ -127,10 +97,13 @@ export function getRootDir() {
|
|
|
127
97
|
return path.dirname(configFile);
|
|
128
98
|
}
|
|
129
99
|
|
|
130
|
-
export function checkConfigFile() {
|
|
100
|
+
export function checkConfigFile(exit = false) {
|
|
131
101
|
let configFile = getClosestConfigFile();
|
|
132
102
|
if (!configFile) {
|
|
133
103
|
console.log(chalk.red('Error: ') + `Config file 'mops.toml' not found. Please run ${chalk.green('mops init')} first`);
|
|
104
|
+
if (exit) {
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
134
107
|
return false;
|
|
135
108
|
}
|
|
136
109
|
return true;
|
|
@@ -246,7 +219,7 @@ export function formatDir(name : string, version : string) {
|
|
|
246
219
|
|
|
247
220
|
export function formatGithubDir(name : string, repo : string) {
|
|
248
221
|
const {branch, commitHash} = parseGithubURL(repo);
|
|
249
|
-
return path.join(getRootDir(), '.mops/_github', `${name}#${branch}` + (commitHash ? `@${commitHash}` : ''));
|
|
222
|
+
return path.join(getRootDir(), '.mops/_github', `${name}#${branch.replaceAll('/', '___')}` + (commitHash ? `@${commitHash}` : ''));
|
|
250
223
|
}
|
|
251
224
|
|
|
252
225
|
export function readDfxJson() : any {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ic-mops",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mops": "dist/bin/mops.js",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"*",
|
|
12
12
|
"!network.txt",
|
|
13
|
+
"!Dockerfile",
|
|
14
|
+
"!verify.sh",
|
|
15
|
+
"!build.sh",
|
|
16
|
+
"!DEVELOPMENT.md",
|
|
13
17
|
"!.mops",
|
|
14
18
|
"/templates"
|
|
15
19
|
],
|
|
@@ -24,14 +28,15 @@
|
|
|
24
28
|
"node": ">=18.0.0"
|
|
25
29
|
},
|
|
26
30
|
"scripts": {
|
|
27
|
-
"build": "
|
|
31
|
+
"build": "npm run prepare && npm run bundle",
|
|
32
|
+
"dist": "tsc",
|
|
28
33
|
"bundle": "rm -rf ./bundle && bun build ./cli.ts --outdir ./bundle --target node --minify --external @napi-rs/lzma --external fsevents --format esm --define '__dirname=import.meta.dirname' && npm run bundle:fix && npm run bundle:copy && npm run bundle:package-json && npm run bundle:tar",
|
|
29
34
|
"bundle:fix": "npx -y rexreplace 'new URL\\(\"\\.\\./templates' 'new URL(\"./templates' bundle/cli.js",
|
|
30
35
|
"bundle:copy": "cp -r commands/bench bundle && cp -r bin declarations templates package.json bundle",
|
|
31
36
|
"bundle:package-json": "tsx bundle-package-json.ts",
|
|
32
|
-
"bundle:tar": "touch bundle/cli.tgz && tar --exclude bundle/cli.tgz -
|
|
37
|
+
"bundle:tar": "rm -f bundle/cli.tgz && touch -t 200101010101 bundle/cli.tgz && find bundle -exec touch -d '1970-01-01 00:00:00' {} + && tar --sort name --exclude bundle/cli.tgz -cvf - bundle | gzip -n > bundle/cli.tgz",
|
|
33
38
|
"copy": "cp -r commands/bench dist/commands && cp -r declarations templates package.json bin dist | true",
|
|
34
|
-
"prepare": "npm run
|
|
39
|
+
"prepare": "rm -rf dist && npm run dist && npm run copy && npm run fix-dist",
|
|
35
40
|
"fix-dist": "tsx ./fix-dist.ts",
|
|
36
41
|
"release": "tsx release-cli.ts",
|
|
37
42
|
"check": "tsc --project tsconfig.json --noEmit",
|
|
@@ -39,13 +44,13 @@
|
|
|
39
44
|
"esbuild": "esbuild"
|
|
40
45
|
},
|
|
41
46
|
"dependencies": {
|
|
42
|
-
"@dfinity/agent": "2.
|
|
43
|
-
"@dfinity/candid": "2.
|
|
44
|
-
"@dfinity/identity": "2.
|
|
45
|
-
"@dfinity/identity-secp256k1": "2.
|
|
46
|
-
"@dfinity/principal": "2.
|
|
47
|
+
"@dfinity/agent": "2.1.0",
|
|
48
|
+
"@dfinity/candid": "2.1.0",
|
|
49
|
+
"@dfinity/identity": "2.1.0",
|
|
50
|
+
"@dfinity/identity-secp256k1": "2.1.0",
|
|
51
|
+
"@dfinity/principal": "2.1.0",
|
|
47
52
|
"@iarna/toml": "2.2.5",
|
|
48
|
-
"@noble/hashes": "1.
|
|
53
|
+
"@noble/hashes": "1.5.0",
|
|
49
54
|
"as-table": "1.0.55",
|
|
50
55
|
"buffer": "6.0.3",
|
|
51
56
|
"cacheable-request": "12.0.1",
|
|
@@ -53,12 +58,13 @@
|
|
|
53
58
|
"chalk": "5.3.0",
|
|
54
59
|
"chokidar": "3.6.0",
|
|
55
60
|
"commander": "12.1.0",
|
|
56
|
-
"debounce": "2.1.
|
|
61
|
+
"debounce": "2.1.1",
|
|
57
62
|
"decomp-tarxz": "0.1.1",
|
|
58
63
|
"decompress": "4.2.1",
|
|
59
64
|
"del": "7.1.0",
|
|
60
65
|
"dhall-to-json-cli": "1.7.6",
|
|
61
|
-
"execa": "9.3.
|
|
66
|
+
"execa": "9.3.1",
|
|
67
|
+
"filesize": "10.1.6",
|
|
62
68
|
"fs-extra": "11.2.0",
|
|
63
69
|
"get-folder-size": "5.0.0",
|
|
64
70
|
"glob": "11.0.0",
|
|
@@ -73,7 +79,7 @@
|
|
|
73
79
|
"node-fetch": "3.3.2",
|
|
74
80
|
"octokit": "3.1.2",
|
|
75
81
|
"pem-file": "1.0.1",
|
|
76
|
-
"pic-ic": "0.
|
|
82
|
+
"pic-ic": "0.5.3",
|
|
77
83
|
"prompts": "2.4.2",
|
|
78
84
|
"semver": "7.6.3",
|
|
79
85
|
"stream-to-promise": "3.0.0",
|
|
@@ -87,21 +93,15 @@
|
|
|
87
93
|
"@types/fs-extra": "11.0.4",
|
|
88
94
|
"@types/glob": "8.1.0",
|
|
89
95
|
"@types/ncp": "2.0.8",
|
|
90
|
-
"@types/node": "22.
|
|
96
|
+
"@types/node": "22.5.4",
|
|
91
97
|
"@types/prompts": "2.4.9",
|
|
92
98
|
"@types/semver": "7.5.8",
|
|
93
99
|
"@types/stream-to-promise": "2.2.4",
|
|
94
100
|
"@types/tar": "6.1.13",
|
|
101
|
+
"bun": "1.1.27",
|
|
102
|
+
"esbuild": "0.23.1",
|
|
95
103
|
"eslint": "8.57.0",
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"tsx": "4.16.5",
|
|
99
|
-
"typescript": "5.5.4"
|
|
100
|
-
},
|
|
101
|
-
"overrides": {
|
|
102
|
-
"@dfinity/agent": "2.0.0",
|
|
103
|
-
"@dfinity/identity": "2.0.0",
|
|
104
|
-
"@dfinity/principal": "2.0.0",
|
|
105
|
-
"@dfinity/candid": "2.0.0"
|
|
104
|
+
"tsx": "4.19.1",
|
|
105
|
+
"typescript": "5.6.2"
|
|
106
106
|
}
|
|
107
107
|
}
|
package/release-cli.ts
CHANGED
|
@@ -11,9 +11,10 @@ import {findChangelogEntry} from './helpers/find-changelog-entry.js';
|
|
|
11
11
|
|
|
12
12
|
let __dirname = new URL('.', import.meta.url).pathname;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
execSync('
|
|
14
|
+
// build using Docker
|
|
15
|
+
execSync('./build.sh', {stdio: 'inherit', cwd: __dirname});
|
|
16
16
|
|
|
17
|
+
let commitHash = process.env.COMMIT_HASH || execSync('git rev-parse HEAD').toString().trim();
|
|
17
18
|
let version = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'package.json'), 'utf8')).version;
|
|
18
19
|
let major = semver.parse(version)?.major;
|
|
19
20
|
let tag = semver.parse(version)?.prerelease[0] || 'latest';
|
|
@@ -22,6 +23,8 @@ let data = fs.readFileSync(path.resolve(__dirname, 'bundle/cli.tgz'));
|
|
|
22
23
|
let hash = bytesToHex(sha256(data));
|
|
23
24
|
let size = data.byteLength;
|
|
24
25
|
|
|
26
|
+
console.log(`Commit hash of release: ${commitHash}`);
|
|
27
|
+
|
|
25
28
|
fs.cpSync(path.resolve(__dirname, 'bundle/cli.tgz'), path.resolve(__dirname, `../cli-releases/versions/${version}.tgz`), {force: false, errorOnExist: true});
|
|
26
29
|
|
|
27
30
|
fs.cpSync(path.resolve(__dirname, `../cli-releases/versions/${version}.tgz`), path.resolve(__dirname, `../cli-releases/versions/${tag}.tgz`), {force: true, errorOnExist: false, recursive: true});
|
|
@@ -39,6 +42,7 @@ type Releases = {
|
|
|
39
42
|
time : number;
|
|
40
43
|
size : number;
|
|
41
44
|
hash : string;
|
|
45
|
+
commitHash ?: string;
|
|
42
46
|
url : string;
|
|
43
47
|
relseaseNotes : string;
|
|
44
48
|
}>;
|
|
@@ -55,6 +59,7 @@ releases.versions[version] = {
|
|
|
55
59
|
time: new Date().getTime(),
|
|
56
60
|
size,
|
|
57
61
|
relseaseNotes: releaseNotes,
|
|
62
|
+
commitHash: commitHash,
|
|
58
63
|
url: `https://cli.mops.one/versions/${version}.tgz`,
|
|
59
64
|
hash,
|
|
60
65
|
};
|
package/resolve-packages.ts
CHANGED
|
@@ -5,15 +5,20 @@ import {checkConfigFile, getRootDir, parseGithubURL, readConfig} from './mops.js
|
|
|
5
5
|
import {VesselConfig, readVesselConfig} from './vessel.js';
|
|
6
6
|
import {Config, Dependency} from './types.js';
|
|
7
7
|
import {getDepCacheDir, getDepCacheName} from './cache.js';
|
|
8
|
+
import {getPackageId} from './helpers/get-package-id.js';
|
|
8
9
|
|
|
9
|
-
export async function resolvePackages({
|
|
10
|
+
export async function resolvePackages({conflicts = 'ignore' as 'warning' | 'error' | 'ignore'} = {}) : Promise<Record<string, string>> {
|
|
10
11
|
if (!checkConfigFile()) {
|
|
11
12
|
return {};
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
let rootDir = getRootDir();
|
|
15
16
|
let packages : Record<string, Dependency & {isRoot : boolean;}> = {};
|
|
16
|
-
let versions : Record<string,
|
|
17
|
+
let versions : Record<string, Array<{
|
|
18
|
+
isMopsPackage : boolean;
|
|
19
|
+
version : string;
|
|
20
|
+
dependencyOf : string;
|
|
21
|
+
}>> = {};
|
|
17
22
|
|
|
18
23
|
let compareVersions = (a : string = '0.0.0', b : string = '0.0.0') => {
|
|
19
24
|
let ap = a.split('.').map((x : string) => parseInt(x)) as [number, number, number];
|
|
@@ -95,19 +100,32 @@ export async function resolvePackages({verbose = false} = {}) : Promise<Record<s
|
|
|
95
100
|
|
|
96
101
|
// collect nested deps
|
|
97
102
|
if (nestedConfig) {
|
|
98
|
-
await collectDeps(nestedConfig, localNestedDir);
|
|
103
|
+
await collectDeps(nestedConfig, localNestedDir, false);
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
if (!versions[name]) {
|
|
102
107
|
versions[name] = [];
|
|
103
108
|
}
|
|
104
109
|
|
|
110
|
+
let parentPkgId = isRoot ? '<root>' : '';
|
|
111
|
+
if ('package' in config) {
|
|
112
|
+
parentPkgId = getPackageId(config.package?.name || '', config.package?.version || '');
|
|
113
|
+
}
|
|
114
|
+
|
|
105
115
|
if (repo) {
|
|
106
116
|
const {branch} = parseGithubURL(repo);
|
|
107
|
-
versions[name]?.push(
|
|
117
|
+
versions[name]?.push({
|
|
118
|
+
version: branch,
|
|
119
|
+
dependencyOf: parentPkgId,
|
|
120
|
+
isMopsPackage: false,
|
|
121
|
+
});
|
|
108
122
|
}
|
|
109
123
|
else if (version) {
|
|
110
|
-
versions[name]?.push(
|
|
124
|
+
versions[name]?.push({
|
|
125
|
+
version: version,
|
|
126
|
+
dependencyOf: parentPkgId,
|
|
127
|
+
isMopsPackage: true,
|
|
128
|
+
});
|
|
111
129
|
}
|
|
112
130
|
}
|
|
113
131
|
};
|
|
@@ -116,14 +134,27 @@ export async function resolvePackages({verbose = false} = {}) : Promise<Record<s
|
|
|
116
134
|
await collectDeps(config, rootDir, true);
|
|
117
135
|
|
|
118
136
|
// show conflicts
|
|
119
|
-
|
|
137
|
+
let hasConflicts = false;
|
|
138
|
+
|
|
139
|
+
if (conflicts !== 'ignore') {
|
|
120
140
|
for (let [dep, vers] of Object.entries(versions)) {
|
|
121
|
-
|
|
122
|
-
|
|
141
|
+
let majors = new Set(vers.filter(x => x.isMopsPackage).map(x => x.version.split('.')[0]));
|
|
142
|
+
if (majors.size > 1) {
|
|
143
|
+
console.error(chalk.reset('') + chalk.redBright(conflicts === 'error' ? 'Error!' : 'Warning!'), `Conflicting versions of dependency "${dep}"`);
|
|
144
|
+
|
|
145
|
+
for (let {version, dependencyOf} of vers.reverse()) {
|
|
146
|
+
console.error(chalk.reset(' ') + `${dep} ${chalk.bold.red(version.split('.')[0])}.${version.split('.').slice(1).join('.')} is dependency of ${chalk.bold(dependencyOf)}`);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
hasConflicts = true;
|
|
123
150
|
}
|
|
124
151
|
}
|
|
125
152
|
}
|
|
126
153
|
|
|
154
|
+
if (conflicts === 'error' && hasConflicts) {
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
|
|
127
158
|
return Object.fromEntries(
|
|
128
159
|
Object.entries(packages).map(([name, pkg]) => {
|
|
129
160
|
let version : string;
|
package/types.ts
CHANGED
package/vessel.ts
CHANGED
|
@@ -111,7 +111,7 @@ export const downloadFromGithub = async (repo : string, dest : string, onProgres
|
|
|
111
111
|
// Prevent `onError` being called twice.
|
|
112
112
|
readStream.off('error', reject);
|
|
113
113
|
const tmpDir = path.resolve(process.cwd(), '.mops/_tmp/');
|
|
114
|
-
const tmpFile = path.resolve(tmpDir, `${gitName}@${commitHash || branch}.zip`);
|
|
114
|
+
const tmpFile = path.resolve(tmpDir, `${gitName}@${(commitHash || branch).replaceAll('/', '___')}.zip`);
|
|
115
115
|
|
|
116
116
|
try {
|
|
117
117
|
mkdirSync(tmpDir, {recursive: true});
|
package/DEVELOPMENT.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Mops CLI
|
|
2
|
-
|
|
3
|
-
1. Update the version in `package.json` using `npm version` command.
|
|
4
|
-
|
|
5
|
-
2. Update changelog in `CHANGELOG.md` file.
|
|
6
|
-
|
|
7
|
-
3. Publish.
|
|
8
|
-
|
|
9
|
-
## Publish to npm
|
|
10
|
-
```
|
|
11
|
-
npm publish
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Publish on chain
|
|
15
|
-
|
|
16
|
-
1. Prepeare release
|
|
17
|
-
```
|
|
18
|
-
npm run release
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
2. Deploy canister
|
|
22
|
-
(from root of the project)
|
|
23
|
-
```
|
|
24
|
-
dfx deploy --network ic --no-wallet cli
|
|
25
|
-
```
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import {Buffer} from 'node:buffer';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import prompts from 'prompts';
|
|
6
|
-
import {deleteSync} from 'del';
|
|
7
|
-
import {globalConfigDir} from '../mops.js';
|
|
8
|
-
import {encrypt} from '../pem.js';
|
|
9
|
-
|
|
10
|
-
type ImportIdentityOptions = {
|
|
11
|
-
encrypt : boolean;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export async function importPem(data : string, options : ImportIdentityOptions = {encrypt: true}) {
|
|
15
|
-
try {
|
|
16
|
-
if (!fs.existsSync(globalConfigDir)) {
|
|
17
|
-
fs.mkdirSync(globalConfigDir);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let password = '';
|
|
21
|
-
|
|
22
|
-
if (options.encrypt) {
|
|
23
|
-
let res = await prompts({
|
|
24
|
-
type: 'invisible',
|
|
25
|
-
name: 'password',
|
|
26
|
-
message: 'Enter password to encrypt identity.pem',
|
|
27
|
-
});
|
|
28
|
-
password = res.password;
|
|
29
|
-
|
|
30
|
-
if (!password) {
|
|
31
|
-
let res = await prompts({
|
|
32
|
-
type: 'confirm',
|
|
33
|
-
name: 'ok',
|
|
34
|
-
message: 'Are you sure you don\'t want to protect your identity.pem with a password?',
|
|
35
|
-
});
|
|
36
|
-
if (!res.ok) {
|
|
37
|
-
console.log('aborted');
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let identityPem = path.resolve(globalConfigDir, 'identity.pem');
|
|
44
|
-
let identityPemEncrypted = path.resolve(globalConfigDir, 'identity.pem.encrypted');
|
|
45
|
-
|
|
46
|
-
deleteSync([identityPem, identityPemEncrypted], {force: true});
|
|
47
|
-
|
|
48
|
-
// encrypted
|
|
49
|
-
if (password) {
|
|
50
|
-
let encrypted = await encrypt(Buffer.from(data), password);
|
|
51
|
-
fs.writeFileSync(identityPemEncrypted, encrypted);
|
|
52
|
-
}
|
|
53
|
-
// unencrypted
|
|
54
|
-
else {
|
|
55
|
-
fs.writeFileSync(identityPem, data);
|
|
56
|
-
}
|
|
57
|
-
console.log(chalk.green('Success'));
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
console.log(chalk.red('Error: ') + err);
|
|
61
|
-
}
|
|
62
|
-
}
|
package/commands/whoami.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import {getIdentity} from '../mops.js';
|
|
3
|
-
|
|
4
|
-
export async function whoami() {
|
|
5
|
-
let identity = await getIdentity();
|
|
6
|
-
if (identity) {
|
|
7
|
-
console.log(identity.getPrincipal().toText());
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
console.log(chalk.red('Error: ') + 'identity not found. Run ' + chalk.greenBright('mops import-identity') + ' command.');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { Buffer } from 'node:buffer';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import prompts from 'prompts';
|
|
6
|
-
import { deleteSync } from 'del';
|
|
7
|
-
import { globalConfigDir } from '../mops.js';
|
|
8
|
-
import { encrypt } from '../pem.js';
|
|
9
|
-
export async function importPem(data, options = { encrypt: true }) {
|
|
10
|
-
try {
|
|
11
|
-
if (!fs.existsSync(globalConfigDir)) {
|
|
12
|
-
fs.mkdirSync(globalConfigDir);
|
|
13
|
-
}
|
|
14
|
-
let password = '';
|
|
15
|
-
if (options.encrypt) {
|
|
16
|
-
let res = await prompts({
|
|
17
|
-
type: 'invisible',
|
|
18
|
-
name: 'password',
|
|
19
|
-
message: 'Enter password to encrypt identity.pem',
|
|
20
|
-
});
|
|
21
|
-
password = res.password;
|
|
22
|
-
if (!password) {
|
|
23
|
-
let res = await prompts({
|
|
24
|
-
type: 'confirm',
|
|
25
|
-
name: 'ok',
|
|
26
|
-
message: 'Are you sure you don\'t want to protect your identity.pem with a password?',
|
|
27
|
-
});
|
|
28
|
-
if (!res.ok) {
|
|
29
|
-
console.log('aborted');
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
let identityPem = path.resolve(globalConfigDir, 'identity.pem');
|
|
35
|
-
let identityPemEncrypted = path.resolve(globalConfigDir, 'identity.pem.encrypted');
|
|
36
|
-
deleteSync([identityPem, identityPemEncrypted], { force: true });
|
|
37
|
-
// encrypted
|
|
38
|
-
if (password) {
|
|
39
|
-
let encrypted = await encrypt(Buffer.from(data), password);
|
|
40
|
-
fs.writeFileSync(identityPemEncrypted, encrypted);
|
|
41
|
-
}
|
|
42
|
-
// unencrypted
|
|
43
|
-
else {
|
|
44
|
-
fs.writeFileSync(identityPem, data);
|
|
45
|
-
}
|
|
46
|
-
console.log(chalk.green('Success'));
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
console.log(chalk.red('Error: ') + err);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function whoami(): Promise<void>;
|
package/dist/commands/whoami.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import { getIdentity } from '../mops.js';
|
|
3
|
-
export async function whoami() {
|
|
4
|
-
let identity = await getIdentity();
|
|
5
|
-
if (identity) {
|
|
6
|
-
console.log(identity.getPrincipal().toText());
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
console.log(chalk.red('Error: ') + 'identity not found. Run ' + chalk.greenBright('mops import-identity') + ' command.');
|
|
10
|
-
}
|
|
11
|
-
}
|