ic-mops 0.2.1 → 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 +5 -5
- package/commands/install-all.js +3 -2
- package/commands/install.js +4 -3
- package/commands/sources.js +15 -11
- package/commands/uninstall.js +5 -4
- package/declarations/main/index.js +3 -3
- package/declarations/main/main.did +2 -2
- package/declarations/main/main.did.js +2 -2
- package/mops.js +15 -10
- package/package.json +6 -1
- package/vessel.js +35 -32
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
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import {checkApiCompatibility, mainActor, readDfxJson, writeConfig} from '../mops.js';
|
|
5
5
|
import {installAll} from './install-all.js';
|
|
6
|
-
import {
|
|
6
|
+
import {readVesselConfig} from '../vessel.js';
|
|
7
7
|
|
|
8
8
|
export async function init(name = '') {
|
|
9
9
|
let configFile = path.join(process.cwd(), 'mops.toml');
|
|
@@ -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
|
-
const res = await readVesselConfig(process.cwd(), {
|
|
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
|
@@ -13,9 +13,10 @@ export async function installAll({verbose} = {}) {
|
|
|
13
13
|
const deps = Object.values(config.dependencies || {});
|
|
14
14
|
|
|
15
15
|
for (let {name, repo, version} of deps) {
|
|
16
|
-
if (repo){
|
|
16
|
+
if (repo) {
|
|
17
17
|
await installFromGithub(name, repo, {verbose});
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
19
20
|
await install(name, version, {verbose});
|
|
20
21
|
}
|
|
21
22
|
}
|
package/commands/install.js
CHANGED
|
@@ -4,7 +4,7 @@ import logUpdate from 'log-update';
|
|
|
4
4
|
import {checkConfigFile, formatDir, getHighestVersion, mainActor, progressBar, readConfig, storageActor} from '../mops.js';
|
|
5
5
|
import {parallel} from '../parallel.js';
|
|
6
6
|
import chalk from 'chalk';
|
|
7
|
-
import {
|
|
7
|
+
import {installFromGithub} from '../vessel.js';
|
|
8
8
|
|
|
9
9
|
export async function install(pkg, version = '', {verbose, silent, dep} = {}) {
|
|
10
10
|
if (!checkConfigFile()) {
|
|
@@ -91,9 +91,10 @@ 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
|
+
else {
|
|
97
98
|
await install(name, version, {verbose});
|
|
98
99
|
}
|
|
99
100
|
}
|
package/commands/sources.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
-
import {formatDir, formatGithubDir,
|
|
5
|
-
import {
|
|
4
|
+
import {formatDir, formatGithubDir, parseGithubURL, readConfig} from '../mops.js';
|
|
5
|
+
import {readVesselConfig} from '../vessel.js';
|
|
6
6
|
|
|
7
7
|
function rootDir(cwd = process.cwd()) {
|
|
8
8
|
let configFile = path.join(cwd, 'mops.toml');
|
|
@@ -47,11 +47,13 @@ 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
54
|
return -1;
|
|
54
|
-
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
55
57
|
return 1;
|
|
56
58
|
}
|
|
57
59
|
};
|
|
@@ -75,11 +77,11 @@ export async function sources({verbose} = {}) {
|
|
|
75
77
|
|
|
76
78
|
let nestedConfig;
|
|
77
79
|
|
|
78
|
-
if (repo){
|
|
80
|
+
if (repo) {
|
|
79
81
|
const dir = formatGithubDir(name, repo);
|
|
80
82
|
nestedConfig = await readVesselConfig(dir) || {};
|
|
81
83
|
}
|
|
82
|
-
else{
|
|
84
|
+
else {
|
|
83
85
|
const dir = formatDir(name, version) + '/mops.toml';
|
|
84
86
|
nestedConfig = readConfig(dir);
|
|
85
87
|
}
|
|
@@ -90,10 +92,11 @@ export async function sources({verbose} = {}) {
|
|
|
90
92
|
versions[name] = [];
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
if (repo){
|
|
95
|
+
if (repo) {
|
|
94
96
|
const {branch} = parseGithubURL(repo);
|
|
95
97
|
versions[name].push(branch);
|
|
96
|
-
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
97
100
|
versions[name].push(version);
|
|
98
101
|
}
|
|
99
102
|
}
|
|
@@ -114,9 +117,10 @@ export async function sources({verbose} = {}) {
|
|
|
114
117
|
// sources
|
|
115
118
|
for (let [name, {repo, version}] of Object.entries(packages)) {
|
|
116
119
|
let pkgDir;
|
|
117
|
-
if (repo){
|
|
120
|
+
if (repo) {
|
|
118
121
|
pkgDir = path.relative(process.cwd(), formatGithubDir(name, repo)) + '/src';
|
|
119
|
-
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
120
124
|
pkgDir = path.relative(process.cwd(), formatDir(name, version)) + '/src';
|
|
121
125
|
}
|
|
122
126
|
|
package/commands/uninstall.js
CHANGED
|
@@ -2,7 +2,7 @@ import {checkConfigFile, readConfig} from '../mops.js';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import del from 'del';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
import {
|
|
5
|
+
import {formatDir, formatGithubDir} from '../mops.js';
|
|
6
6
|
|
|
7
7
|
export async function uninstall(pkg, version) {
|
|
8
8
|
if (!checkConfigFile()) {
|
|
@@ -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,9 +22,10 @@ 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
|
+
else {
|
|
28
29
|
pkgDir = formatDir(pkg, version);
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -2,7 +2,7 @@ import { Actor, HttpAgent } from "@dfinity/agent";
|
|
|
2
2
|
|
|
3
3
|
// Imports and re-exports candid interface
|
|
4
4
|
import { idlFactory } from './main.did.js';
|
|
5
|
-
export { idlFactory
|
|
5
|
+
export { idlFactory} from './main.did.js';
|
|
6
6
|
// CANISTER_ID is replaced by webpack based on node environment
|
|
7
7
|
export const canisterId = process.env.MAIN_CANISTER_ID;
|
|
8
8
|
|
|
@@ -18,7 +18,7 @@ export const createActor = (canisterId, options = {}) => {
|
|
|
18
18
|
|
|
19
19
|
See https://internetcomputer.org/docs/current/developer-docs/updates/release-notes/ for migration instructions`);
|
|
20
20
|
const agent = options.agent || new HttpAgent({ ...options.agentOptions });
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
// Fetch root key for certificate validation during development
|
|
23
23
|
if (process.env.DFX_NETWORK !== "ic") {
|
|
24
24
|
agent.fetchRootKey().catch(err => {
|
|
@@ -34,7 +34,7 @@ See https://internetcomputer.org/docs/current/developer-docs/updates/release-not
|
|
|
34
34
|
...(options ? options.actorOptions : {}),
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
/**
|
|
39
39
|
* A ready-to-use agent for the main canister
|
|
40
40
|
* @type {import("@dfinity/agent").ActorSubclass<import("./main.did.js")._SERVICE>}
|
|
@@ -124,8 +124,8 @@ service : {
|
|
|
124
124
|
StorageId;
|
|
125
125
|
StorageStats;
|
|
126
126
|
}) query;
|
|
127
|
-
getTotalDownloads: () -> (nat);
|
|
128
|
-
getTotalPackages: () -> (nat);
|
|
127
|
+
getTotalDownloads: () -> (nat) query;
|
|
128
|
+
getTotalPackages: () -> (nat) query;
|
|
129
129
|
notifyInstall: (PackageName__1, Ver) -> () oneway;
|
|
130
130
|
search: (Text) -> (vec PackageDetails) query;
|
|
131
131
|
startFileUpload: (PublishingId, Text, nat, blob) -> (Result_2);
|
|
@@ -105,8 +105,8 @@ export const idlFactory = ({ IDL }) => {
|
|
|
105
105
|
[IDL.Vec(IDL.Tuple(StorageId, StorageStats))],
|
|
106
106
|
['query'],
|
|
107
107
|
),
|
|
108
|
-
'getTotalDownloads' : IDL.Func([], [IDL.Nat], []),
|
|
109
|
-
'getTotalPackages' : IDL.Func([], [IDL.Nat], []),
|
|
108
|
+
'getTotalDownloads' : IDL.Func([], [IDL.Nat], ['query']),
|
|
109
|
+
'getTotalPackages' : IDL.Func([], [IDL.Nat], ['query']),
|
|
110
110
|
'notifyInstall' : IDL.Func([PackageName__1, Ver], [], ['oneway']),
|
|
111
111
|
'search' : IDL.Func([Text], [IDL.Vec(PackageDetails)], ['query']),
|
|
112
112
|
'startFileUpload' : IDL.Func(
|
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,10 +1,15 @@
|
|
|
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": "https://mops.one",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/ZenVoich/mops.git"
|
|
12
|
+
},
|
|
8
13
|
"dependencies": {
|
|
9
14
|
"@dfinity/agent": "^0.11.0",
|
|
10
15
|
"@dfinity/candid": "^0.11.0",
|
package/vessel.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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';
|
|
10
|
-
import {pipeline} from 'stream
|
|
10
|
+
import {pipeline} from 'stream';
|
|
11
11
|
|
|
12
12
|
const dhallFileToJson = async (filePath) => {
|
|
13
13
|
if (existsSync(filePath)) {
|
|
@@ -16,11 +16,12 @@ const dhallFileToJson = async (filePath) => {
|
|
|
16
16
|
try {
|
|
17
17
|
res = await execaCommand(`dhall-to-json --file ${filePath}`, {preferLocal:true, cwd});
|
|
18
18
|
}
|
|
19
|
-
catch (
|
|
19
|
+
catch (err) {
|
|
20
|
+
console.error('dhall-to-json error:', err);
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
if (res.exitCode === 0){
|
|
24
|
+
if (res.exitCode === 0) {
|
|
24
25
|
return JSON.parse(res.stdout);
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
@@ -33,7 +34,7 @@ const dhallFileToJson = async (filePath) => {
|
|
|
33
34
|
|
|
34
35
|
export const readVesselConfig = async (
|
|
35
36
|
configFile,
|
|
36
|
-
{
|
|
37
|
+
{cache = true} = {cache: true}
|
|
37
38
|
) => {
|
|
38
39
|
const cachedFile = (configFile || process.cwd()) + '/vessel.json';
|
|
39
40
|
|
|
@@ -50,15 +51,15 @@ export const readVesselConfig = async (
|
|
|
50
51
|
if (!vessel || !packageSetArray) return null;
|
|
51
52
|
|
|
52
53
|
let repos = {};
|
|
53
|
-
for (const {
|
|
54
|
-
const {
|
|
54
|
+
for (const {name, repo, version} of packageSetArray) {
|
|
55
|
+
const {org, gitName} = parseGithubURL(repo);
|
|
55
56
|
repos[name] = `https://github.com/${org}/${gitName}#${version}`;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
let config = {
|
|
59
60
|
compiler: vessel.compiler,
|
|
60
61
|
dependencies: vessel.dependencies.map((name) => {
|
|
61
|
-
return {
|
|
62
|
+
return {name, repo: repos[name], version: ''};
|
|
62
63
|
}),
|
|
63
64
|
};
|
|
64
65
|
|
|
@@ -77,8 +78,8 @@ export const downloadFromGithub = async (repo, dest, onProgress = null) => {
|
|
|
77
78
|
|
|
78
79
|
const promise = new Promise((resolve, reject) => {
|
|
79
80
|
|
|
80
|
-
readStream.on('downloadProgress', ({
|
|
81
|
-
onProgress?.(transferred, total || 2 * (1024 ** 2)
|
|
81
|
+
readStream.on('downloadProgress', ({transferred, total}) => {
|
|
82
|
+
onProgress?.(transferred, total || 2 * (1024 ** 2));
|
|
82
83
|
});
|
|
83
84
|
|
|
84
85
|
readStream.on('response', (response) => {
|
|
@@ -97,28 +98,30 @@ export const downloadFromGithub = async (repo, dest, onProgress = null) => {
|
|
|
97
98
|
try {
|
|
98
99
|
mkdirSync(tmpDir, {recursive: true});
|
|
99
100
|
|
|
100
|
-
pipeline(readStream, createWriteStream(tmpFile))
|
|
101
|
-
|
|
101
|
+
pipeline(readStream, createWriteStream(tmpFile), (err) => {
|
|
102
|
+
if (err) {
|
|
103
|
+
del.sync([tmpDir]);
|
|
104
|
+
reject(err);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
102
107
|
let options = {
|
|
103
108
|
extract: true,
|
|
104
109
|
strip: 1,
|
|
105
110
|
headers: {
|
|
106
|
-
accept: 'application/zip'
|
|
107
|
-
}
|
|
111
|
+
accept: 'application/zip',
|
|
112
|
+
},
|
|
108
113
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
} catch (err) {
|
|
114
|
+
decompress(tmpFile, dest, options).then((unzippedFiles) => {
|
|
115
|
+
del.sync([tmpDir]);
|
|
116
|
+
resolve(unzippedFiles);
|
|
117
|
+
}).catch(err => {
|
|
118
|
+
del.sync([tmpDir]);
|
|
119
|
+
reject(err);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
122
125
|
del.sync([tmpDir]);
|
|
123
126
|
reject(err);
|
|
124
127
|
}
|
|
@@ -134,7 +137,7 @@ export const installFromGithub = async (name, repo, options = {})=>{
|
|
|
134
137
|
const {branch} = parseGithubURL(repo);
|
|
135
138
|
const dir = formatGithubDir(name, repo);
|
|
136
139
|
|
|
137
|
-
if (existsSync(dir)){
|
|
140
|
+
if (existsSync(dir)) {
|
|
138
141
|
silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${name}@${branch} (cache) from Github`);
|
|
139
142
|
}
|
|
140
143
|
else {
|
|
@@ -157,9 +160,9 @@ export const installFromGithub = async (name, repo, options = {})=>{
|
|
|
157
160
|
|
|
158
161
|
const config = await readVesselConfig(dir);
|
|
159
162
|
|
|
160
|
-
if (config){
|
|
161
|
-
for (const {name, repo} of config.dependencies){
|
|
162
|
-
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});
|
|
163
166
|
}
|
|
164
167
|
}
|
|
165
168
|
};
|