ic-mops 0.7.0 → 0.7.2
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/cli.js +1 -0
- package/commands/add.js +11 -4
- package/commands/install-all.js +4 -2
- package/commands/install.js +2 -1
- package/commands/publish.js +19 -2
- package/commands/sources.js +5 -1
- package/declarations/main/main.did.d.ts +2 -2
- package/mops.js +24 -17
- package/package.json +1 -1
package/cli.js
CHANGED
package/commands/add.js
CHANGED
|
@@ -5,14 +5,21 @@ import {checkConfigFile, getHighestVersion, parseGithubURL, readConfig, writeCon
|
|
|
5
5
|
import {installFromGithub} from '../vessel.js';
|
|
6
6
|
import {install} from './install.js';
|
|
7
7
|
|
|
8
|
-
export async function add(name, {verbose} = {}) {
|
|
8
|
+
export async function add(name, {verbose, dev} = {}) {
|
|
9
9
|
if (!checkConfigFile()) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
let config = readConfig();
|
|
14
|
-
if (
|
|
15
|
-
config
|
|
14
|
+
if (dev) {
|
|
15
|
+
if (!config['dev-dependencies']) {
|
|
16
|
+
config['dev-dependencies'] = {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
if (!config.dependencies) {
|
|
21
|
+
config.dependencies = {};
|
|
22
|
+
}
|
|
16
23
|
}
|
|
17
24
|
|
|
18
25
|
let pkgDetails;
|
|
@@ -68,7 +75,7 @@ export async function add(name, {verbose} = {}) {
|
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
77
|
|
|
71
|
-
config
|
|
78
|
+
config[dev ? 'dev-dependencies' : 'dependencies'][pkgDetails.name] = pkgDetails;
|
|
72
79
|
writeConfig(config);
|
|
73
80
|
|
|
74
81
|
logUpdate.clear();
|
package/commands/install-all.js
CHANGED
|
@@ -10,9 +10,11 @@ export async function installAll({verbose, silent} = {}) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
let config = readConfig();
|
|
13
|
-
|
|
13
|
+
let deps = Object.values(config.dependencies || {});
|
|
14
|
+
let devDeps = Object.values(config['dev-dependencies'] || {});
|
|
15
|
+
let allDeps = [...deps, ...devDeps];
|
|
14
16
|
|
|
15
|
-
for (let {name, repo, path, version} of
|
|
17
|
+
for (let {name, repo, path, version} of allDeps) {
|
|
16
18
|
if (repo) {
|
|
17
19
|
await installFromGithub(name, repo, {verbose, silent});
|
|
18
20
|
}
|
package/commands/install.js
CHANGED
|
@@ -110,7 +110,8 @@ export async function install(pkg, version = '', {verbose, silent, dep} = {}) {
|
|
|
110
110
|
// install dependencies
|
|
111
111
|
let ok = true;
|
|
112
112
|
let config = readConfig(path.join(dir, 'mops.toml'));
|
|
113
|
-
|
|
113
|
+
let deps = Object.values(config.dependencies || {});
|
|
114
|
+
for (const {name, repo, version} of deps) {
|
|
114
115
|
if (repo) {
|
|
115
116
|
await installFromGithub(name, repo, {silent, verbose});
|
|
116
117
|
}
|
package/commands/publish.js
CHANGED
|
@@ -17,7 +17,7 @@ export async function publish() {
|
|
|
17
17
|
|
|
18
18
|
// validate
|
|
19
19
|
for (let key of Object.keys(config)) {
|
|
20
|
-
if (!['package', 'dependencies', 'scripts'].includes(key)) {
|
|
20
|
+
if (!['package', 'dependencies', 'dev-dependencies', 'scripts'].includes(key)) {
|
|
21
21
|
console.log(chalk.red('Error: ') + `Unknown config section [${key}]`);
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
@@ -112,6 +112,21 @@ export async function publish() {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
if (config['dev-dependencies']) {
|
|
116
|
+
if (Object.keys(config['dev-dependencies']).length > 100) {
|
|
117
|
+
console.log(chalk.red('Error: ') + 'max dev-dependencies is 100');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
for (let dep of Object.values(config['dev-dependencies'])) {
|
|
122
|
+
if (dep.path) {
|
|
123
|
+
console.log(chalk.red('Error: ') + 'you can\'t publish packages with local dev-dependencies');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
delete dep.path;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
115
130
|
if (config.package.keywords) {
|
|
116
131
|
for (let keyword of config.package.keywords) {
|
|
117
132
|
if (keyword.length > 20) {
|
|
@@ -147,7 +162,7 @@ export async function publish() {
|
|
|
147
162
|
moc: config.package.moc || '',
|
|
148
163
|
donation: config.package.donation || '',
|
|
149
164
|
dependencies: Object.values(config.dependencies || {}),
|
|
150
|
-
devDependencies: [],
|
|
165
|
+
devDependencies: Object.values(config['dev-dependencies'] || {}),
|
|
151
166
|
scripts: [],
|
|
152
167
|
};
|
|
153
168
|
|
|
@@ -156,6 +171,8 @@ export async function publish() {
|
|
|
156
171
|
'README.md',
|
|
157
172
|
'LICENSE',
|
|
158
173
|
'!.mops/**',
|
|
174
|
+
'!test/**',
|
|
175
|
+
'!**/*.test.mo',
|
|
159
176
|
];
|
|
160
177
|
let files = config.package.files || ['**/*.mo'];
|
|
161
178
|
files = [...files, ...defaultFiles];
|
package/commands/sources.js
CHANGED
|
@@ -59,7 +59,11 @@ export async function sources({verbose} = {}) {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
let collectDeps = async (config, isRoot = false) => {
|
|
62
|
-
|
|
62
|
+
let allDeps = [...Object.values(config.dependencies || {})];
|
|
63
|
+
if (isRoot) {
|
|
64
|
+
allDeps = [...allDeps, ...Object.values(config['dev-dependencies'] || {})];
|
|
65
|
+
}
|
|
66
|
+
for (const pkgDetails of allDeps) {
|
|
63
67
|
const {name, repo, version} = pkgDetails;
|
|
64
68
|
|
|
65
69
|
// take root dep version or bigger one
|
|
@@ -103,12 +103,12 @@ export interface _SERVICE {
|
|
|
103
103
|
'notifyInstall' : ActorMethod<[PackageName__1, Ver], undefined>,
|
|
104
104
|
'search' : ActorMethod<[Text], Array<PackageDetails>>,
|
|
105
105
|
'startFileUpload' : ActorMethod<
|
|
106
|
-
[PublishingId, Text, bigint, Uint8Array
|
|
106
|
+
[PublishingId, Text, bigint, Uint8Array],
|
|
107
107
|
Result_2
|
|
108
108
|
>,
|
|
109
109
|
'startPublish' : ActorMethod<[PackageConfigV2], Result_1>,
|
|
110
110
|
'uploadFileChunk' : ActorMethod<
|
|
111
|
-
[PublishingId, FileId, bigint, Uint8Array
|
|
111
|
+
[PublishingId, FileId, bigint, Uint8Array],
|
|
112
112
|
Result
|
|
113
113
|
>,
|
|
114
114
|
}
|
package/mops.js
CHANGED
|
@@ -124,33 +124,40 @@ export function readConfig(configFile = path.join(process.cwd(), 'mops.toml')) {
|
|
|
124
124
|
let text = fs.readFileSync(configFile).toString();
|
|
125
125
|
let toml = TOML.parse(text);
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
}
|
|
127
|
+
let processDeps = (deps) => {
|
|
128
|
+
Object.entries(deps).forEach(([name, data]) => {
|
|
129
|
+
if (!data || typeof data !== 'string') {
|
|
130
|
+
throw Error(`Invalid dependency value ${name} = "${data}"`);
|
|
131
|
+
}
|
|
132
|
+
if (data.startsWith('https://github.com/')) {
|
|
133
|
+
deps[name] = {name, repo: data, version: ''};
|
|
134
|
+
}
|
|
135
|
+
else if (data.match(/^(\.?\.)?\//)) {
|
|
136
|
+
deps[name] = {name, repo: '', path: data, version: ''};
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
deps[name] = {name, repo: '', version: data};
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
processDeps(toml.dependencies || {});
|
|
145
|
+
processDeps(toml['dev-dependencies'] || {});
|
|
143
146
|
|
|
144
147
|
return toml;
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
export function writeConfig(config, configFile = path.join(process.cwd(), 'mops.toml')) {
|
|
148
151
|
const deps = config.dependencies || {};
|
|
149
|
-
|
|
150
152
|
Object.entries(deps).forEach(([name, {repo, path, version}]) => {
|
|
151
153
|
deps[name] = repo || path || version;
|
|
152
154
|
});
|
|
153
155
|
|
|
156
|
+
const devDeps = config['dev-dependencies'] || {};
|
|
157
|
+
Object.entries(devDeps).forEach(([name, {repo, path, version}]) => {
|
|
158
|
+
devDeps[name] = repo || path || version;
|
|
159
|
+
});
|
|
160
|
+
|
|
154
161
|
fs.writeFileSync(configFile, TOML.stringify(config).trim());
|
|
155
162
|
}
|
|
156
163
|
|