ic-mops 1.1.0-pre.0 → 1.1.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 (74) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/bin/moc-wrapper.sh +1 -1
  3. package/bundle/cli.tgz +0 -0
  4. package/check-requirements.ts +1 -1
  5. package/cli.ts +18 -0
  6. package/commands/bench.ts +1 -1
  7. package/commands/install/install-all.ts +2 -2
  8. package/commands/replica.ts +33 -3
  9. package/commands/sources.ts +1 -1
  10. package/commands/sync.ts +4 -19
  11. package/commands/test/mmf1.ts +4 -0
  12. package/commands/test/reporters/silent-reporter.ts +22 -4
  13. package/commands/test/test.ts +74 -10
  14. package/commands/watch/deployer.ts +155 -0
  15. package/commands/watch/error-checker.ts +87 -0
  16. package/commands/watch/generator.ts +99 -0
  17. package/commands/watch/globMoFiles.ts +16 -0
  18. package/commands/watch/parseDfxJson.ts +64 -0
  19. package/commands/watch/tester.ts +81 -0
  20. package/commands/watch/warning-checker.ts +133 -0
  21. package/commands/watch/watch.ts +90 -0
  22. package/declarations/main/main.did +16 -10
  23. package/declarations/main/main.did.d.ts +19 -10
  24. package/declarations/main/main.did.js +25 -11
  25. package/dist/bin/moc-wrapper.sh +1 -1
  26. package/dist/check-requirements.js +1 -1
  27. package/dist/cli.js +16 -0
  28. package/dist/commands/bench.js +1 -1
  29. package/dist/commands/install/install-all.js +2 -2
  30. package/dist/commands/replica.d.ts +2 -2
  31. package/dist/commands/replica.js +26 -3
  32. package/dist/commands/sources.d.ts +1 -1
  33. package/dist/commands/sources.js +1 -1
  34. package/dist/commands/sync.js +3 -18
  35. package/dist/commands/test/mmf1.d.ts +1 -0
  36. package/dist/commands/test/mmf1.js +3 -0
  37. package/dist/commands/test/reporters/silent-reporter.d.ts +6 -1
  38. package/dist/commands/test/reporters/silent-reporter.js +18 -5
  39. package/dist/commands/test/test.d.ts +1 -1
  40. package/dist/commands/test/test.js +62 -10
  41. package/dist/commands/watch/deployer.d.ts +24 -0
  42. package/dist/commands/watch/deployer.js +125 -0
  43. package/dist/commands/watch/error-checker.d.ts +13 -0
  44. package/dist/commands/watch/error-checker.js +76 -0
  45. package/dist/commands/watch/generator.d.ts +21 -0
  46. package/dist/commands/watch/generator.js +79 -0
  47. package/dist/commands/watch/globMoFiles.d.ts +1 -0
  48. package/dist/commands/watch/globMoFiles.js +14 -0
  49. package/dist/commands/watch/parseDfxJson.d.ts +2 -0
  50. package/dist/commands/watch/parseDfxJson.js +22 -0
  51. package/dist/commands/watch/tester.d.ts +19 -0
  52. package/dist/commands/watch/tester.js +63 -0
  53. package/dist/commands/watch/warning-checker.d.ts +20 -0
  54. package/dist/commands/watch/warning-checker.js +111 -0
  55. package/dist/commands/watch/watch.d.ts +7 -0
  56. package/dist/commands/watch/watch.js +79 -0
  57. package/dist/declarations/main/main.did +16 -10
  58. package/dist/declarations/main/main.did.d.ts +19 -10
  59. package/dist/declarations/main/main.did.js +25 -11
  60. package/dist/helpers/get-moc-path.d.ts +1 -1
  61. package/dist/helpers/get-moc-path.js +17 -3
  62. package/dist/helpers/get-moc-version.d.ts +1 -1
  63. package/dist/helpers/get-moc-version.js +17 -5
  64. package/dist/integrity.js +3 -2
  65. package/dist/package.json +3 -2
  66. package/dist/parallel.d.ts +1 -1
  67. package/dist/templates/mops-test.yml +4 -2
  68. package/helpers/get-moc-path.ts +19 -3
  69. package/helpers/get-moc-version.ts +17 -5
  70. package/integrity.ts +3 -2
  71. package/package.json +3 -2
  72. package/parallel.ts +2 -2
  73. package/templates/mops-test.yml +4 -2
  74. package/test +0 -4
@@ -14,9 +14,11 @@ jobs:
14
14
  steps:
15
15
  - uses: actions/checkout@v4
16
16
  - uses: ZenVoich/setup-mops@v1
17
+ with:
18
+ mops-version: 1
17
19
 
18
- - name: make sure moc is installed
19
- run: mops toolchain bin moc || mops toolchain use moc latest
20
+ - name: install mops packages
21
+ run: mops install
20
22
 
21
23
  - name: run tests
22
24
  run: mops test
@@ -1,13 +1,29 @@
1
1
  import process from 'node:process';
2
- import {execSync} from 'node:child_process';
2
+ import {execFileSync} from 'node:child_process';
3
3
 
4
- export function getMocPath() : string {
4
+ export function getMocPath(throwIfNotFound = false) : string {
5
5
  let mocPath = process.env.DFX_MOC_PATH;
6
6
  if (!mocPath) {
7
- mocPath = execSync('dfx cache show').toString().trim() + '/moc';
7
+ try {
8
+ mocPath = execFileSync('dfx', ['cache', 'show']).toString().trim() + '/moc';
9
+ }
10
+ catch (e) {
11
+ mocPath = '';
12
+ }
8
13
  }
9
14
  if (!mocPath) {
10
15
  mocPath = 'moc';
11
16
  }
17
+
18
+ if (throwIfNotFound) {
19
+ try {
20
+ execFileSync(mocPath, ['--version']);
21
+ }
22
+ catch (e) {
23
+ console.error(e);
24
+ throw new Error('moc not found');
25
+ }
26
+ }
27
+
12
28
  return mocPath;
13
29
  }
@@ -1,8 +1,20 @@
1
- import {execSync} from 'node:child_process';
1
+ import {execFileSync} from 'node:child_process';
2
2
  import {getMocPath} from './get-moc-path.js';
3
3
 
4
- export function getMocVersion() : string {
5
- let mocPath = getMocPath();
6
- let match = execSync(mocPath).toString().trim().match(/Motoko compiler ([^\s]+) .*/);
7
- return match?.[1] || '';
4
+ export function getMocVersion(throwOnError = false) : string {
5
+ let mocPath = getMocPath(false);
6
+ if (!mocPath) {
7
+ return '';
8
+ }
9
+ try {
10
+ let match = execFileSync(mocPath, ['--version']).toString().trim().match(/Motoko compiler ([^\s]+) .*/);
11
+ return match?.[1] || '';
12
+ }
13
+ catch (e) {
14
+ if (throwOnError) {
15
+ console.error(e);
16
+ throw new Error('moc not found');
17
+ }
18
+ return '';
19
+ }
8
20
  }
package/integrity.ts CHANGED
@@ -167,6 +167,7 @@ export async function updateLockFile() {
167
167
 
168
168
  // compare hashes of local files with hashes from the lock file
169
169
  export async function checkLockFile(force = false) {
170
+ let supportedVersions = [1, 2, 3];
170
171
  let rootDir = getRootDir();
171
172
  let lockFile = path.join(rootDir, 'mops.lock');
172
173
 
@@ -183,9 +184,9 @@ export async function checkLockFile(force = false) {
183
184
  let packageIds = await getResolvedMopsPackageIds();
184
185
 
185
186
  // check lock file version
186
- if (lockFileJsonGeneric.version !== 1 && lockFileJsonGeneric.version !== 2 && lockFileJsonGeneric.version !== 3) {
187
+ if (!supportedVersions.includes(lockFileJsonGeneric.version)) {
187
188
  console.error('Integrity check failed');
188
- console.error(`Invalid lock file version: ${lockFileJsonGeneric.version}. Supported versions: 1, 2, 3`);
189
+ console.error(`Invalid lock file version: ${lockFileJsonGeneric.version}. Supported versions: ${supportedVersions.join(', ')}`);
189
190
  process.exit(1);
190
191
  }
191
192
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ic-mops",
3
- "version": "1.1.0-pre.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mops": "dist/bin/mops.js",
@@ -80,6 +80,7 @@
80
80
  "octokit": "3.1.2",
81
81
  "pem-file": "1.0.1",
82
82
  "pic-ic": "0.5.3",
83
+ "promisify-child-process": "4.1.2",
83
84
  "prompts": "2.4.2",
84
85
  "semver": "7.6.3",
85
86
  "stream-to-promise": "3.0.0",
@@ -93,7 +94,7 @@
93
94
  "@types/fs-extra": "11.0.4",
94
95
  "@types/glob": "8.1.0",
95
96
  "@types/ncp": "2.0.8",
96
- "@types/node": "22.5.4",
97
+ "@types/node": "22.7.4",
97
98
  "@types/prompts": "2.4.9",
98
99
  "@types/semver": "7.5.8",
99
100
  "@types/stream-to-promise": "2.2.4",
package/parallel.ts CHANGED
@@ -1,4 +1,4 @@
1
- export async function parallel(threads : number, items : any[], fn : CallableFunction) {
1
+ export async function parallel<T>(threads : number, items : T[], fn : (item : T) => Promise<void>) {
2
2
  return new Promise<void>((resolve) => {
3
3
  let busyThreads = 0;
4
4
  items = items.slice();
@@ -14,7 +14,7 @@ export async function parallel(threads : number, items : any[], fn : CallableFun
14
14
  return;
15
15
  }
16
16
  busyThreads++;
17
- fn(items.shift()).then(() => {
17
+ fn(items.shift() as T).then(() => {
18
18
  busyThreads--;
19
19
  loop();
20
20
  });
@@ -14,9 +14,11 @@ jobs:
14
14
  steps:
15
15
  - uses: actions/checkout@v4
16
16
  - uses: ZenVoich/setup-mops@v1
17
+ with:
18
+ mops-version: 1
17
19
 
18
- - name: make sure moc is installed
19
- run: mops toolchain bin moc || mops toolchain use moc latest
20
+ - name: install mops packages
21
+ run: mops install
20
22
 
21
23
  - name: run tests
22
24
  run: mops test
package/test DELETED
@@ -1,4 +0,0 @@
1
- dev, toolchain 89s
2
- no dev, no toolchain 68s
3
- lockfile, toolchain 60s
4
- lockfile, no toolchain 49s