ic-mops 0.2.2 → 0.2.3
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 +10 -7
- package/commands/init.js +3 -3
- package/commands/install-all.js +1 -1
- package/commands/install.js +1 -1
- package/commands/sources.js +5 -5
- package/commands/uninstall.js +2 -2
- package/mops.js +15 -10
- package/package.json +2 -2
- package/vessel.js +13 -13
package/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import {checkApiCompatibility, getHighestVersion, getNetwork, parseGithubURL, re
|
|
|
14
14
|
import {whoami} from './commands/whoami.js';
|
|
15
15
|
import {installAll} from './commands/install-all.js';
|
|
16
16
|
import logUpdate from 'log-update';
|
|
17
|
-
import {
|
|
17
|
+
import {installFromGithub} from './vessel.js';
|
|
18
18
|
|
|
19
19
|
let cwd = process.cwd();
|
|
20
20
|
let configFile = path.join(cwd, 'mops.toml');
|
|
@@ -63,7 +63,7 @@ program
|
|
|
63
63
|
let pkgDetails;
|
|
64
64
|
let existingPkg = config.dependencies[pkg];
|
|
65
65
|
|
|
66
|
-
if (pkg.startsWith('https://github.com') || pkg.split('/') > 1){
|
|
66
|
+
if (pkg.startsWith('https://github.com') || pkg.split('/') > 1) {
|
|
67
67
|
const {org, gitName, branch} = parseGithubURL(pkg);
|
|
68
68
|
|
|
69
69
|
pkgDetails = {
|
|
@@ -74,7 +74,8 @@ program
|
|
|
74
74
|
|
|
75
75
|
existingPkg = config.dependencies[pkgDetails.name];
|
|
76
76
|
|
|
77
|
-
}
|
|
77
|
+
}
|
|
78
|
+
else if (!existingPkg || !existingPkg.repo) {
|
|
78
79
|
let versionRes = await getHighestVersion(pkg);
|
|
79
80
|
if (versionRes.err) {
|
|
80
81
|
console.log(chalk.red('Error: ') + versionRes.err);
|
|
@@ -87,23 +88,25 @@ program
|
|
|
87
88
|
version: versionRes.ok
|
|
88
89
|
};
|
|
89
90
|
|
|
90
|
-
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
91
93
|
options.silent || logUpdate(`Installing ${existingPkg.name}@${existingPkg.version} (cache) from Github`);
|
|
92
94
|
return;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
const {name, repo, version} = pkgDetails;
|
|
96
98
|
|
|
97
|
-
if (repo){
|
|
99
|
+
if (repo) {
|
|
98
100
|
// pkg name conflict with an installed mops pkg
|
|
99
|
-
if (existingPkg && !existingPkg.repo){
|
|
101
|
+
if (existingPkg && !existingPkg.repo) {
|
|
100
102
|
console.log(chalk.red('Error: ') + `Conflicting Package Name '${name}`);
|
|
101
103
|
console.log('Consider entering the repo url and assigning a new name in the \'mops.toml\' file');
|
|
102
104
|
return;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
await installFromGithub(name, repo, {verbose: options.verbose});
|
|
106
|
-
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
107
110
|
await install(name, version, {verbose: options.verbose});
|
|
108
111
|
}
|
|
109
112
|
|
package/commands/init.js
CHANGED
|
@@ -20,16 +20,16 @@ export async function init(name = '') {
|
|
|
20
20
|
|
|
21
21
|
const vesselFile = path.join(process.cwd(), 'vessel.dhall');
|
|
22
22
|
|
|
23
|
-
if (fs.existsSync(vesselFile)){
|
|
23
|
+
if (fs.existsSync(vesselFile)) {
|
|
24
24
|
console.log('Reading vessel.dhall file');
|
|
25
25
|
const res = await readVesselConfig(process.cwd(), {cache: false});
|
|
26
26
|
vesselConfig = {...res};
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
if (vesselConfig.dependencies){
|
|
29
|
+
if (vesselConfig.dependencies) {
|
|
30
30
|
config.dependencies = {};
|
|
31
31
|
|
|
32
|
-
for (const dep of (vesselConfig.dependencies || [])){
|
|
32
|
+
for (const dep of (vesselConfig.dependencies || [])) {
|
|
33
33
|
config.dependencies[dep.name] = dep;
|
|
34
34
|
}
|
|
35
35
|
}
|
package/commands/install-all.js
CHANGED
package/commands/install.js
CHANGED
|
@@ -91,7 +91,7 @@ export async function install(pkg, version = '', {verbose, silent, dep} = {}) {
|
|
|
91
91
|
// install dependencies
|
|
92
92
|
let config = readConfig(path.join(dir, 'mops.toml'));
|
|
93
93
|
for (const {name, repo, version} of Object.values(config.dependencies || {})) {
|
|
94
|
-
if (repo){
|
|
94
|
+
if (repo) {
|
|
95
95
|
await installFromGithub(name, repo, {verbose});
|
|
96
96
|
}
|
|
97
97
|
else {
|
package/commands/sources.js
CHANGED
|
@@ -47,10 +47,10 @@ export async function sources({verbose} = {}) {
|
|
|
47
47
|
const {branch: a} = parseGithubURL(repoA);
|
|
48
48
|
const {branch: b} = parseGithubURL(repoB);
|
|
49
49
|
|
|
50
|
-
if (gitVerRegex.test(a) && gitVerRegex.test(b)){
|
|
50
|
+
if (gitVerRegex.test(a) && gitVerRegex.test(b)) {
|
|
51
51
|
return compareVersions(a.substring(1) , b.substring(1));
|
|
52
52
|
}
|
|
53
|
-
else if (!gitVerRegex.test(a)){
|
|
53
|
+
else if (!gitVerRegex.test(a)) {
|
|
54
54
|
return -1;
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
@@ -77,7 +77,7 @@ export async function sources({verbose} = {}) {
|
|
|
77
77
|
|
|
78
78
|
let nestedConfig;
|
|
79
79
|
|
|
80
|
-
if (repo){
|
|
80
|
+
if (repo) {
|
|
81
81
|
const dir = formatGithubDir(name, repo);
|
|
82
82
|
nestedConfig = await readVesselConfig(dir) || {};
|
|
83
83
|
}
|
|
@@ -92,7 +92,7 @@ export async function sources({verbose} = {}) {
|
|
|
92
92
|
versions[name] = [];
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
if (repo){
|
|
95
|
+
if (repo) {
|
|
96
96
|
const {branch} = parseGithubURL(repo);
|
|
97
97
|
versions[name].push(branch);
|
|
98
98
|
}
|
|
@@ -117,7 +117,7 @@ export async function sources({verbose} = {}) {
|
|
|
117
117
|
// sources
|
|
118
118
|
for (let [name, {repo, version}] of Object.entries(packages)) {
|
|
119
119
|
let pkgDir;
|
|
120
|
-
if (repo){
|
|
120
|
+
if (repo) {
|
|
121
121
|
pkgDir = path.relative(process.cwd(), formatGithubDir(name, repo)) + '/src';
|
|
122
122
|
}
|
|
123
123
|
else {
|
package/commands/uninstall.js
CHANGED
|
@@ -14,7 +14,7 @@ export async function uninstall(pkg, version) {
|
|
|
14
14
|
|
|
15
15
|
const pkgDetails = config.dependencies[pkg];
|
|
16
16
|
|
|
17
|
-
if (!pkgDetails){
|
|
17
|
+
if (!pkgDetails) {
|
|
18
18
|
console.log(`No dependency to remove ${pkg} = "${version}"`);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
@@ -22,7 +22,7 @@ export async function uninstall(pkg, version) {
|
|
|
22
22
|
const {repo} = pkgDetails;
|
|
23
23
|
let pkgDir;
|
|
24
24
|
|
|
25
|
-
if (repo){
|
|
25
|
+
if (repo) {
|
|
26
26
|
pkgDir = formatGithubDir(pkg, repo);
|
|
27
27
|
}
|
|
28
28
|
else {
|
package/mops.js
CHANGED
|
@@ -107,17 +107,17 @@ export async function getHighestVersion(pkgName) {
|
|
|
107
107
|
return actor.getHighestVersion(pkgName);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
export function parseGithubURL(href){
|
|
110
|
+
export function parseGithubURL(href) {
|
|
111
111
|
const url = new URL(href);
|
|
112
112
|
const branch = url.hash?.substring(1) || 'master';
|
|
113
113
|
|
|
114
114
|
let [org, gitName] = url.pathname.split('/').filter(path => !!path);
|
|
115
115
|
|
|
116
|
-
if (gitName.endsWith('.git')){
|
|
116
|
+
if (gitName.endsWith('.git')) {
|
|
117
117
|
gitName = gitName.substring(0, gitName.length - 4);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
return {
|
|
120
|
+
return {org, gitName, branch};
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
export function readConfig(configFile = path.join(process.cwd(), 'mops.toml')) {
|
|
@@ -127,9 +127,13 @@ export function readConfig(configFile = path.join(process.cwd(), 'mops.toml')) {
|
|
|
127
127
|
const deps = toml.dependencies || {};
|
|
128
128
|
|
|
129
129
|
Object.entries(deps).forEach(([name, data])=>{
|
|
130
|
-
if (data
|
|
130
|
+
if (!data || typeof data !== 'string') {
|
|
131
|
+
throw Error(`Invalid dependency value ${name} = "${data}"`);
|
|
132
|
+
}
|
|
133
|
+
if (data.startsWith('https://github.com/')) {
|
|
131
134
|
deps[name] = {name, repo: data, version: ''};
|
|
132
|
-
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
133
137
|
deps[name] = {name, repo: '', version: data};
|
|
134
138
|
}
|
|
135
139
|
});
|
|
@@ -141,9 +145,10 @@ export function writeConfig(config, configFile = path.join(process.cwd(), 'mops.
|
|
|
141
145
|
const deps = config.dependencies || {};
|
|
142
146
|
|
|
143
147
|
Object.entries(deps).forEach(([name, {repo, version}])=>{
|
|
144
|
-
if (repo){
|
|
148
|
+
if (repo) {
|
|
145
149
|
deps[name] = repo;
|
|
146
|
-
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
147
152
|
deps[name] = version;
|
|
148
153
|
}
|
|
149
154
|
});
|
|
@@ -151,12 +156,12 @@ export function writeConfig(config, configFile = path.join(process.cwd(), 'mops.
|
|
|
151
156
|
fs.writeFileSync(configFile, TOML.stringify(config).trim());
|
|
152
157
|
}
|
|
153
158
|
|
|
154
|
-
export function formatDir(name, version){
|
|
159
|
+
export function formatDir(name, version) {
|
|
155
160
|
return path.join(process.cwd(), '.mops', `${name}@${version}`);
|
|
156
161
|
}
|
|
157
162
|
|
|
158
|
-
export function formatGithubDir(name, repo){
|
|
159
|
-
const {
|
|
163
|
+
export function formatGithubDir(name, repo) {
|
|
164
|
+
const {branch} = parseGithubURL(repo);
|
|
160
165
|
return path.join(process.cwd(), '.mops/_github', `${name}@${branch}`);
|
|
161
166
|
}
|
|
162
167
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ic-mops",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mops": "cli.js"
|
|
7
7
|
},
|
|
8
|
-
"homepage": "
|
|
8
|
+
"homepage": "https://mops.one",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/ZenVoich/mops.git"
|
package/vessel.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {existsSync, mkdirSync, createWriteStream, readFileSync, writeFileSync} from 'fs';
|
|
2
2
|
import del from 'del';
|
|
3
|
-
import {
|
|
3
|
+
import {execaCommand} from 'execa';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import logUpdate from 'log-update';
|
|
6
|
-
import {
|
|
6
|
+
import {formatGithubDir, parseGithubURL, progressBar} from './mops.js';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import got from 'got';
|
|
9
9
|
import decompress from 'decompress';
|
|
@@ -21,7 +21,7 @@ const dhallFileToJson = async (filePath) => {
|
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
if (res.exitCode === 0){
|
|
24
|
+
if (res.exitCode === 0) {
|
|
25
25
|
return JSON.parse(res.stdout);
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
@@ -34,7 +34,7 @@ const dhallFileToJson = async (filePath) => {
|
|
|
34
34
|
|
|
35
35
|
export const readVesselConfig = async (
|
|
36
36
|
configFile,
|
|
37
|
-
{
|
|
37
|
+
{cache = true} = {cache: true}
|
|
38
38
|
) => {
|
|
39
39
|
const cachedFile = (configFile || process.cwd()) + '/vessel.json';
|
|
40
40
|
|
|
@@ -51,15 +51,15 @@ export const readVesselConfig = async (
|
|
|
51
51
|
if (!vessel || !packageSetArray) return null;
|
|
52
52
|
|
|
53
53
|
let repos = {};
|
|
54
|
-
for (const {
|
|
55
|
-
const {
|
|
54
|
+
for (const {name, repo, version} of packageSetArray) {
|
|
55
|
+
const {org, gitName} = parseGithubURL(repo);
|
|
56
56
|
repos[name] = `https://github.com/${org}/${gitName}#${version}`;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
let config = {
|
|
60
60
|
compiler: vessel.compiler,
|
|
61
61
|
dependencies: vessel.dependencies.map((name) => {
|
|
62
|
-
return {
|
|
62
|
+
return {name, repo: repos[name], version: ''};
|
|
63
63
|
}),
|
|
64
64
|
};
|
|
65
65
|
|
|
@@ -78,8 +78,8 @@ export const downloadFromGithub = async (repo, dest, onProgress = null) => {
|
|
|
78
78
|
|
|
79
79
|
const promise = new Promise((resolve, reject) => {
|
|
80
80
|
|
|
81
|
-
readStream.on('downloadProgress', ({
|
|
82
|
-
onProgress?.(transferred, total || 2 * (1024 ** 2)
|
|
81
|
+
readStream.on('downloadProgress', ({transferred, total}) => {
|
|
82
|
+
onProgress?.(transferred, total || 2 * (1024 ** 2));
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
readStream.on('response', (response) => {
|
|
@@ -137,7 +137,7 @@ export const installFromGithub = async (name, repo, options = {})=>{
|
|
|
137
137
|
const {branch} = parseGithubURL(repo);
|
|
138
138
|
const dir = formatGithubDir(name, repo);
|
|
139
139
|
|
|
140
|
-
if (existsSync(dir)){
|
|
140
|
+
if (existsSync(dir)) {
|
|
141
141
|
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${name}@${branch} (cache) from Github`);
|
|
142
142
|
}
|
|
143
143
|
else {
|
|
@@ -160,9 +160,9 @@ export const installFromGithub = async (name, repo, options = {})=>{
|
|
|
160
160
|
|
|
161
161
|
const config = await readVesselConfig(dir);
|
|
162
162
|
|
|
163
|
-
if (config){
|
|
164
|
-
for (const {name, repo} of config.dependencies){
|
|
165
|
-
await installFromGithub(name, repo, {verbose, silent, dep: true
|
|
163
|
+
if (config) {
|
|
164
|
+
for (const {name, repo} of config.dependencies) {
|
|
165
|
+
await installFromGithub(name, repo, {verbose, silent, dep: true});
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
};
|