ic-mops 0.19.1 → 0.20.1

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.
Files changed (96) hide show
  1. package/.gitignore +3 -0
  2. package/{cache.js → cache.ts} +8 -8
  3. package/{cli.js → cli.ts} +5 -5
  4. package/commands/{add.js → add.ts} +16 -8
  5. package/commands/{bump.js → bump.ts} +5 -5
  6. package/commands/{docs.js → docs.ts} +10 -10
  7. package/commands/{import-identity.js → import-identity.ts} +7 -7
  8. package/commands/{init.js → init.ts} +20 -17
  9. package/commands/{install-all.js → install-all.ts} +1 -1
  10. package/commands/{install.js → install.ts} +11 -11
  11. package/commands/{mmf1.js → mmf1.ts} +20 -18
  12. package/commands/{publish.js → publish.ts} +29 -16
  13. package/commands/{remove.js → remove.ts} +23 -16
  14. package/commands/{search.js → search.ts} +2 -2
  15. package/commands/self-update.ts +6 -0
  16. package/commands/{sources.js → sources.ts} +30 -24
  17. package/commands/{template.js → template.ts} +2 -2
  18. package/commands/{test.js → test.ts} +24 -19
  19. package/commands/{user.js → user.ts} +7 -2
  20. package/declarations/main/index.js +0 -2
  21. package/declarations/main/main.did +4 -1
  22. package/declarations/main/main.did.d.ts +4 -4
  23. package/declarations/main/main.did.js +20 -20
  24. package/declarations/storage/index.d.ts +50 -0
  25. package/declarations/storage/index.js +3 -11
  26. package/dist/cache.d.ts +5 -0
  27. package/dist/cache.js +46 -0
  28. package/dist/cli.d.ts +2 -0
  29. package/dist/cli.js +265 -0
  30. package/dist/commands/add.d.ts +4 -0
  31. package/dist/commands/add.js +82 -0
  32. package/dist/commands/bump.d.ts +1 -0
  33. package/dist/commands/bump.js +50 -0
  34. package/dist/commands/docs.d.ts +3 -0
  35. package/dist/commands/docs.js +78 -0
  36. package/dist/commands/import-identity.d.ts +1 -0
  37. package/dist/commands/import-identity.js +47 -0
  38. package/dist/commands/init.d.ts +1 -0
  39. package/dist/commands/init.js +82 -0
  40. package/dist/commands/install-all.d.ts +4 -0
  41. package/dist/commands/install-all.js +29 -0
  42. package/dist/commands/install.d.ts +5 -0
  43. package/dist/commands/install.js +110 -0
  44. package/dist/commands/mmf1.d.ts +21 -0
  45. package/dist/commands/mmf1.js +93 -0
  46. package/dist/commands/publish.d.ts +3 -0
  47. package/dist/commands/publish.js +254 -0
  48. package/dist/commands/remove.d.ts +5 -0
  49. package/dist/commands/remove.js +83 -0
  50. package/dist/commands/search.d.ts +1 -0
  51. package/dist/commands/search.js +36 -0
  52. package/dist/commands/self-update.d.ts +3 -0
  53. package/dist/commands/self-update.js +5 -0
  54. package/dist/commands/sources.d.ts +3 -0
  55. package/dist/commands/sources.js +124 -0
  56. package/dist/commands/template.d.ts +1 -0
  57. package/dist/commands/template.js +28 -0
  58. package/dist/commands/test.d.ts +4 -0
  59. package/dist/commands/test.js +201 -0
  60. package/dist/commands/user.d.ts +2 -0
  61. package/dist/commands/user.js +23 -0
  62. package/dist/commands/whoami.d.ts +1 -0
  63. package/dist/commands/whoami.js +11 -0
  64. package/dist/declarations/main/index.d.ts +50 -0
  65. package/dist/declarations/main/index.js +41 -0
  66. package/dist/declarations/main/main.did +222 -0
  67. package/dist/declarations/main/main.did.d.ts +198 -0
  68. package/dist/declarations/main/main.did.js +218 -0
  69. package/dist/declarations/storage/index.d.ts +50 -0
  70. package/dist/declarations/storage/index.js +30 -0
  71. package/dist/declarations/storage/storage.did +46 -0
  72. package/dist/declarations/storage/storage.did.d.ts +37 -0
  73. package/dist/declarations/storage/storage.did.js +38 -0
  74. package/dist/mops.d.ts +33 -0
  75. package/dist/mops.js +259 -0
  76. package/dist/package.json +79 -0
  77. package/dist/parallel.d.ts +1 -0
  78. package/dist/parallel.js +24 -0
  79. package/dist/pem.d.ts +5 -0
  80. package/dist/pem.js +49 -0
  81. package/dist/templates/mops-test.yml +30 -0
  82. package/dist/types.d.ts +27 -0
  83. package/dist/types.js +1 -0
  84. package/dist/vessel.d.ts +19 -0
  85. package/dist/vessel.js +154 -0
  86. package/global.d.ts +2 -0
  87. package/{mops.js → mops.ts} +56 -45
  88. package/package.json +44 -19
  89. package/{parallel.js → parallel.ts} +2 -2
  90. package/{pem.js → pem.ts} +12 -11
  91. package/templates/mops-test.yml +1 -1
  92. package/tsconfig.json +16 -0
  93. package/types.ts +29 -0
  94. package/{vessel.js → vessel.ts} +37 -25
  95. package/commands/self-update.js +0 -6
  96. /package/commands/{whoami.js → whoami.ts} +0 -0
@@ -1,16 +1,16 @@
1
- import {existsSync, mkdirSync, createWriteStream, readFileSync, writeFileSync} from 'fs';
2
- import del from 'del';
1
+ import {existsSync, mkdirSync, createWriteStream, readFileSync, writeFileSync} from 'node:fs';
2
+ import path from 'node:path';
3
+ import {deleteSync} from 'del';
3
4
  import {execaCommand} from 'execa';
4
5
  import chalk from 'chalk';
5
6
  import logUpdate from 'log-update';
6
- import {formatGithubDir, parseGithubURL, progressBar} from './mops.js';
7
- import path from 'path';
8
7
  import got from 'got';
9
8
  import decompress from 'decompress';
10
9
  import {pipeline} from 'stream';
10
+ import {formatGithubDir, parseGithubURL, progressBar} from './mops.js';
11
11
  import {addCache, copyCache, isCached} from './cache.js';
12
12
 
13
- const dhallFileToJson = async (filePath) => {
13
+ const dhallFileToJson = async (filePath: string) => {
14
14
  if (existsSync(filePath)) {
15
15
  let cwd = new URL(path.dirname(import.meta.url)).pathname;
16
16
  let res;
@@ -33,34 +33,46 @@ const dhallFileToJson = async (filePath) => {
33
33
  return null;
34
34
  };
35
35
 
36
- export const readVesselConfig = async (configFile, {cache = true} = {cache: true}) => {
37
- const cachedFile = (configFile || process.cwd()) + '/vessel.json';
36
+ export type VesselConfig = {
37
+ dependencies: VesselDependencies;
38
+ 'dev-dependencies': VesselDependencies;
39
+ };
40
+
41
+ export type VesselDependencies = Array<{
42
+ name: string;
43
+ version?: string; // mops package
44
+ repo?: string; // github package
45
+ path?: string; // local package
46
+ }>;
47
+
48
+ export const readVesselConfig = async (dir: string, {cache = true} = {}): Promise<VesselConfig | null> => {
49
+ const cachedFile = (dir || process.cwd()) + '/vessel.json';
38
50
 
39
51
  if (existsSync(cachedFile)) {
40
- let cachedConfig = readFileSync(cachedFile);
52
+ let cachedConfig = readFileSync(cachedFile).toString();
41
53
  return JSON.parse(cachedConfig);
42
54
  }
43
55
 
44
56
  const [vessel, packageSetArray] = await Promise.all([
45
- dhallFileToJson((configFile || process.cwd()) + '/vessel.dhall'),
46
- dhallFileToJson((configFile || process.cwd()) + '/package-set.dhall')
57
+ dhallFileToJson((dir || process.cwd()) + '/vessel.dhall'),
58
+ dhallFileToJson((dir || process.cwd()) + '/package-set.dhall')
47
59
  ]);
48
60
 
49
61
  if (!vessel || !packageSetArray) {
50
62
  return null;
51
63
  }
52
64
 
53
- let repos = {};
65
+ let repos: Record<string, string> = {};
54
66
  for (const {name, repo, version} of packageSetArray) {
55
67
  const {org, gitName} = parseGithubURL(repo);
56
68
  repos[name] = `https://github.com/${org}/${gitName}#${version}`;
57
69
  }
58
70
 
59
- let config = {
60
- compiler: vessel.compiler,
61
- dependencies: vessel.dependencies.map((name) => {
71
+ let config: VesselConfig = {
72
+ dependencies: vessel.dependencies.map((name: string) => {
62
73
  return {name, repo: repos[name], version: ''};
63
74
  }),
75
+ 'dev-dependencies': [],
64
76
  };
65
77
 
66
78
  if (cache === true) {
@@ -70,7 +82,7 @@ export const readVesselConfig = async (configFile, {cache = true} = {cache: true
70
82
  return config;
71
83
  };
72
84
 
73
- export const downloadFromGithub = async (repo, dest, onProgress = null) => {
85
+ export const downloadFromGithub = async (repo: string, dest: string, onProgress: any) => {
74
86
  const {branch, org, gitName} = parseGithubURL(repo);
75
87
 
76
88
  const zipFile = `https://github.com/${org}/${gitName}/archive/${branch}.zip`;
@@ -103,7 +115,7 @@ export const downloadFromGithub = async (repo, dest, onProgress = null) => {
103
115
 
104
116
  pipeline(readStream, createWriteStream(tmpFile), (err) => {
105
117
  if (err) {
106
- del.sync([tmpDir]);
118
+ deleteSync([tmpDir]);
107
119
  reject(err);
108
120
  }
109
121
  else {
@@ -115,17 +127,17 @@ export const downloadFromGithub = async (repo, dest, onProgress = null) => {
115
127
  },
116
128
  };
117
129
  decompress(tmpFile, dest, options).then((unzippedFiles) => {
118
- del.sync([tmpDir]);
130
+ deleteSync([tmpDir]);
119
131
  resolve(unzippedFiles);
120
132
  }).catch(err => {
121
- del.sync([tmpDir]);
133
+ deleteSync([tmpDir]);
122
134
  reject(err);
123
135
  });
124
136
  }
125
137
  });
126
138
  }
127
139
  catch (err) {
128
- del.sync([tmpDir]);
140
+ deleteSync([tmpDir]);
129
141
  reject(err);
130
142
  }
131
143
  });
@@ -134,9 +146,7 @@ export const downloadFromGithub = async (repo, dest, onProgress = null) => {
134
146
  return promise;
135
147
  };
136
148
 
137
- export const installFromGithub = async (name, repo, options = {}) => {
138
- const {verbose, dep, silent} = options;
139
-
149
+ export const installFromGithub = async (name: string, repo: string, {verbose = false, dep = false, silent = false} = {}) => {
140
150
  const {branch} = parseGithubURL(repo);
141
151
  const dir = formatGithubDir(name, repo);
142
152
  const cacheName = `github_${name}@${branch}`;
@@ -151,7 +161,7 @@ export const installFromGithub = async (name, repo, options = {}) => {
151
161
  else {
152
162
  mkdirSync(dir, {recursive: true});
153
163
 
154
- let progress = (step, total) => {
164
+ let progress = (step: number, total: number) => {
155
165
  silent || logUpdate(`${dep ? 'Dependency' : 'Installing'} ${name}@${branch} ${progressBar(step, total)}`);
156
166
  };
157
167
 
@@ -161,7 +171,7 @@ export const installFromGithub = async (name, repo, options = {}) => {
161
171
  await downloadFromGithub(repo, dir, progress);
162
172
  }
163
173
  catch (err) {
164
- del.sync([dir]);
174
+ deleteSync([dir]);
165
175
  throw err;
166
176
  }
167
177
 
@@ -177,7 +187,9 @@ export const installFromGithub = async (name, repo, options = {}) => {
177
187
 
178
188
  if (config) {
179
189
  for (const {name, repo} of config.dependencies) {
180
- await installFromGithub(name, repo, {verbose, silent, dep: true});
190
+ if (repo) {
191
+ await installFromGithub(name, repo, {verbose, silent, dep: true});
192
+ }
181
193
  }
182
194
  }
183
195
  };
@@ -1,6 +0,0 @@
1
- import child_process from 'child_process';
2
-
3
- export function selfUpdate({detached = false} = {}) {
4
- console.log('Updating mops CLI...');
5
- child_process.execSync('npm i ic-mops -g', {stdio: 'inherit', detached});
6
- }
File without changes