ic-mops 0.9.0 → 0.10.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/.eslintrc.json +0 -0
- package/.gitignore +0 -0
- package/README.md +0 -0
- package/cache.js +0 -0
- package/cli.js +15 -2
- package/commands/add.js +0 -0
- package/commands/docs.js +84 -0
- package/commands/import-identity.js +0 -0
- package/commands/init.js +0 -0
- package/commands/install-all.js +0 -0
- package/commands/install.js +0 -0
- package/commands/mmf1.js +2 -2
- package/commands/publish.js +20 -3
- package/commands/remove.js +0 -0
- package/commands/search.js +0 -0
- package/commands/self-update.js +0 -0
- package/commands/sources.js +0 -0
- package/commands/template.js +0 -0
- package/commands/test.js +0 -0
- package/commands/whoami.js +0 -0
- package/declarations/main/index.d.ts +0 -0
- package/declarations/main/index.js +0 -0
- package/declarations/main/main.did +0 -0
- package/declarations/main/main.did.d.ts +0 -0
- package/declarations/main/main.did.js +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/mops.js +0 -0
- package/package.json +4 -2
- package/parallel.js +0 -0
- package/pem.js +0 -0
- package/templates/mops-test.yml +1 -1
- package/vessel.js +0 -0
- package/commands/uninstall.js +0 -55
package/.eslintrc.json
CHANGED
|
File without changes
|
package/.gitignore
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/cache.js
CHANGED
|
File without changes
|
package/cli.js
CHANGED
|
@@ -18,6 +18,7 @@ import {test} from './commands/test.js';
|
|
|
18
18
|
import {template} from './commands/template.js';
|
|
19
19
|
import {selfUpdate} from './commands/self-update.js';
|
|
20
20
|
import {remove} from './commands/remove.js';
|
|
21
|
+
// import {docs} from './commands/docs.js';
|
|
21
22
|
|
|
22
23
|
program.name('mops');
|
|
23
24
|
|
|
@@ -90,13 +91,14 @@ program
|
|
|
90
91
|
program
|
|
91
92
|
.command('publish')
|
|
92
93
|
.description('Publish package to the mops registry')
|
|
93
|
-
.
|
|
94
|
+
.option('--no-docs', 'Do not generate docs')
|
|
95
|
+
.action(async (options) => {
|
|
94
96
|
if (!checkConfigFile()) {
|
|
95
97
|
process.exit(1);
|
|
96
98
|
}
|
|
97
99
|
let compatible = await checkApiCompatibility();
|
|
98
100
|
if (compatible) {
|
|
99
|
-
await publish();
|
|
101
|
+
await publish(options);
|
|
100
102
|
}
|
|
101
103
|
});
|
|
102
104
|
|
|
@@ -196,6 +198,17 @@ program
|
|
|
196
198
|
await template(options);
|
|
197
199
|
});
|
|
198
200
|
|
|
201
|
+
// docs
|
|
202
|
+
// program
|
|
203
|
+
// .command('docs')
|
|
204
|
+
// .description('Generate documentation (experimental)')
|
|
205
|
+
// .action(async () => {
|
|
206
|
+
// if (!checkConfigFile()) {
|
|
207
|
+
// process.exit(1);
|
|
208
|
+
// }
|
|
209
|
+
// await docs();
|
|
210
|
+
// });
|
|
211
|
+
|
|
199
212
|
// self update
|
|
200
213
|
program
|
|
201
214
|
.command('self-update')
|
package/commands/add.js
CHANGED
|
File without changes
|
package/commands/docs.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {spawn, execSync} from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import glob from 'glob';
|
|
6
|
+
import del from 'del';
|
|
7
|
+
import tar from 'tar';
|
|
8
|
+
import streamToPromise from 'stream-to-promise';
|
|
9
|
+
|
|
10
|
+
import {getRootDir} from '../mops.js';
|
|
11
|
+
|
|
12
|
+
let moDoc;
|
|
13
|
+
|
|
14
|
+
export async function docs({silent} = {}) {
|
|
15
|
+
let rootDir = getRootDir();
|
|
16
|
+
let docsDir = path.join(rootDir, '.mops/_docs');
|
|
17
|
+
let docsDirRelative = path.relative(process.cwd(), path.join(rootDir, '.mops/_docs'));
|
|
18
|
+
|
|
19
|
+
del.sync([docsDir], {force: true});
|
|
20
|
+
|
|
21
|
+
// detect mocv
|
|
22
|
+
if (process.env.DFX_MOC_PATH && process.env.DFX_MOC_PATH.includes('mocv/versions')) {
|
|
23
|
+
moDoc = process.env.DFX_MOC_PATH.replace(/\/moc$/, '/mo-doc');
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
moDoc = execSync('dfx cache show').toString().trim() + '/mo-doc';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// generate docs
|
|
30
|
+
await new Promise((resolve) => {
|
|
31
|
+
let proc = spawn(moDoc, [`--source=${path.join(rootDir, 'src')}`, `--output=${docsDirRelative}`, '--format=adoc']);
|
|
32
|
+
|
|
33
|
+
// stdout
|
|
34
|
+
proc.stdout.on('data', (data) => {
|
|
35
|
+
let text = data.toString().trim();
|
|
36
|
+
silent || console.log('stdout', text);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// stderr
|
|
40
|
+
let stderr = '';
|
|
41
|
+
proc.stderr.on('data', (data) => {
|
|
42
|
+
let text = data.toString().trim();
|
|
43
|
+
if (text.includes('syntax error')) {
|
|
44
|
+
console.log(chalk.red('Error:'), text);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
if (text.includes('No such file or directory') || text.includes('Couldn\'t find a module expression')) {
|
|
48
|
+
silent || console.log(text);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
stderr += text;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// exit
|
|
55
|
+
proc.on('exit', (code) => {
|
|
56
|
+
// if no source files found
|
|
57
|
+
if (code === 2 && !stderr) {
|
|
58
|
+
resolve();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (code !== 0) {
|
|
62
|
+
console.log(chalk.red('Error:'), code, stderr);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
resolve();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// create archive
|
|
70
|
+
let files = glob.sync(`${docsDir}/**/*.adoc`).map(f => path.relative(docsDir, f));
|
|
71
|
+
if (files.length) {
|
|
72
|
+
let stream = tar.create(
|
|
73
|
+
{
|
|
74
|
+
cwd: docsDir,
|
|
75
|
+
gzip: true,
|
|
76
|
+
portable: true,
|
|
77
|
+
},
|
|
78
|
+
files
|
|
79
|
+
).pipe(fs.createWriteStream(path.join(docsDir, 'docs.tgz')));
|
|
80
|
+
await streamToPromise(stream);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
silent || console.log(`${chalk.green('Documentation generated')} at ${docsDirRelative}`);
|
|
84
|
+
}
|
|
File without changes
|
package/commands/init.js
CHANGED
|
File without changes
|
package/commands/install-all.js
CHANGED
|
File without changes
|
package/commands/install.js
CHANGED
|
File without changes
|
package/commands/mmf1.js
CHANGED
|
@@ -28,10 +28,10 @@ export class MMF1 {
|
|
|
28
28
|
|
|
29
29
|
_testStart(name) {
|
|
30
30
|
if (this.stack.length) {
|
|
31
|
-
let suite = this.stack.
|
|
31
|
+
let suite = this.stack[this.stack.length - 1];
|
|
32
32
|
if (this.currSuite !== suite) {
|
|
33
33
|
this.currSuite = suite;
|
|
34
|
-
console.log(' '.repeat((this.stack.length - 1) * 2), (chalk.gray('•')) + '',
|
|
34
|
+
console.log(' '.repeat((this.stack.length - 1) * 2), (chalk.gray('•')) + '', suite);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
this.stack.push(name);
|
package/commands/publish.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
4
|
import logUpdate from 'log-update';
|
|
4
5
|
import {Principal} from '@dfinity/principal';
|
|
5
6
|
import {globbySync} from 'globby';
|
|
6
7
|
import minimatch from 'minimatch';
|
|
7
8
|
import prompts from 'prompts';
|
|
8
|
-
import {checkConfigFile, getIdentity, mainActor, progressBar, readConfig} from '../mops.js';
|
|
9
|
+
import {checkConfigFile, getIdentity, getRootDir, mainActor, progressBar, readConfig} from '../mops.js';
|
|
9
10
|
import {parallel} from '../parallel.js';
|
|
11
|
+
import {docs} from './docs.js';
|
|
10
12
|
|
|
11
|
-
export async function publish() {
|
|
13
|
+
export async function publish({noDocs} = {}) {
|
|
12
14
|
if (!checkConfigFile()) {
|
|
13
15
|
return;
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
let rootDir = getRootDir();
|
|
16
19
|
let config = readConfig();
|
|
17
20
|
|
|
18
21
|
// validate
|
|
@@ -178,6 +181,15 @@ export async function publish() {
|
|
|
178
181
|
files = [...files, ...defaultFiles];
|
|
179
182
|
files = globbySync([...files, ...defaultFiles]);
|
|
180
183
|
|
|
184
|
+
// generate docs
|
|
185
|
+
let docsFile = path.join(rootDir, '.mops/_docs/docs.tgz');
|
|
186
|
+
if (!noDocs) {
|
|
187
|
+
await docs({silent: true});
|
|
188
|
+
if (fs.existsSync(docsFile)) {
|
|
189
|
+
files.unshift(docsFile);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
181
193
|
// check required files
|
|
182
194
|
if (!files.includes('mops.toml')) {
|
|
183
195
|
console.log(chalk.red('Error: ') + ' please add mops.toml file');
|
|
@@ -190,7 +202,7 @@ export async function publish() {
|
|
|
190
202
|
|
|
191
203
|
// check allowed exts
|
|
192
204
|
for (let file of files) {
|
|
193
|
-
if (!minimatch(file, '**/*.{mo,did,md,toml}') && !file.toLowerCase().endsWith('license')) {
|
|
205
|
+
if (!minimatch(file, '**/*.{mo,did,md,toml}') && !file.toLowerCase().endsWith('license') && file !== docsFile) {
|
|
194
206
|
console.log(chalk.red('Error: ') + `file ${file} has unsupported extension. Allowed: .mo, .did, .md, .toml`);
|
|
195
207
|
return;
|
|
196
208
|
}
|
|
@@ -223,6 +235,11 @@ export async function publish() {
|
|
|
223
235
|
let chunkCount = Math.ceil(content.length / chunkSize);
|
|
224
236
|
let firstChunk = Array.from(content.slice(0, chunkSize));
|
|
225
237
|
|
|
238
|
+
// remove path from docs file
|
|
239
|
+
if (file === docsFile) {
|
|
240
|
+
file = path.basename(file);
|
|
241
|
+
}
|
|
242
|
+
|
|
226
243
|
let res = await actor.startFileUpload(puiblishingId, file, chunkCount, firstChunk);
|
|
227
244
|
if (res.err) {
|
|
228
245
|
console.log(chalk.red('Error: ') + res.err);
|
package/commands/remove.js
CHANGED
|
File without changes
|
package/commands/search.js
CHANGED
|
File without changes
|
package/commands/self-update.js
CHANGED
|
File without changes
|
package/commands/sources.js
CHANGED
|
File without changes
|
package/commands/template.js
CHANGED
|
File without changes
|
package/commands/test.js
CHANGED
|
File without changes
|
package/commands/whoami.js
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/mops.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ic-mops",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mops": "cli.js"
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
"ncp": "^2.0.0",
|
|
47
47
|
"node-fetch": "^3.3.0",
|
|
48
48
|
"pem-file": "^1.0.1",
|
|
49
|
-
"prompts": "^2.4.2"
|
|
49
|
+
"prompts": "^2.4.2",
|
|
50
|
+
"stream-to-promise": "^3.0.0",
|
|
51
|
+
"tar": "^6.1.13"
|
|
50
52
|
}
|
|
51
53
|
}
|
package/parallel.js
CHANGED
|
File without changes
|
package/pem.js
CHANGED
|
File without changes
|
package/templates/mops-test.yml
CHANGED
package/vessel.js
CHANGED
|
File without changes
|
package/commands/uninstall.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import {checkConfigFile, readConfig} from '../mops.js';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import del from 'del';
|
|
4
|
-
import chalk from 'chalk';
|
|
5
|
-
import {formatDir, formatGithubDir} from '../mops.js';
|
|
6
|
-
|
|
7
|
-
export async function uninstall(pkg, version) {
|
|
8
|
-
if (!checkConfigFile()) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// TODO: check if deps relate on this package
|
|
13
|
-
const config = readConfig();
|
|
14
|
-
|
|
15
|
-
const pkgDetails = config.dependencies[pkg];
|
|
16
|
-
|
|
17
|
-
if (!pkgDetails) {
|
|
18
|
-
console.log(`No dependency to remove ${pkg} = "${version}"`);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const {repo} = pkgDetails;
|
|
23
|
-
let pkgDir;
|
|
24
|
-
|
|
25
|
-
if (repo) {
|
|
26
|
-
pkgDir = formatGithubDir(pkg, repo);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
pkgDir = formatDir(pkg, version);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!fs.existsSync(pkgDir)) {
|
|
33
|
-
console.log(`No cache to remove ${pkg} = "${version}"`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// don't remove if there are dependents
|
|
38
|
-
// let dependents = getDependents(pkg, version);
|
|
39
|
-
// if (dependents.length) {
|
|
40
|
-
// console.log(`Cache left ${pkg} = "${version}" (dependents: ${dependents})`)
|
|
41
|
-
// return;
|
|
42
|
-
// }
|
|
43
|
-
|
|
44
|
-
del.sync([`${pkgDir}/**`]);
|
|
45
|
-
|
|
46
|
-
console.log(chalk.green('Package removed ') + `${pkg} = "${version}"`);
|
|
47
|
-
|
|
48
|
-
// remove dependencies
|
|
49
|
-
// let text = fs.readFileSync(path.join(pkgDir, 'mops.toml')).toString();
|
|
50
|
-
// let config = TOML.parse(text);
|
|
51
|
-
|
|
52
|
-
// for (let [name, version] of Object.entries(config.dependencies)) {
|
|
53
|
-
// remove(name, version);
|
|
54
|
-
// }
|
|
55
|
-
}
|