@rljson/io 0.0.41 → 0.0.42

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.
@@ -1,103 +1,103 @@
1
- /*
2
- * @license
3
- * Copyright (c) 2025 Rljson
4
- *
5
- * Use of this source code is governed by terms that can be
6
- * found in the LICENSE file in the root of this package.
7
- */
8
-
9
- // Create a folder dist/conformance-tests if it does not exist
10
- import { existsSync } from 'fs';
11
- import fs from 'fs/promises';
12
- import path from 'path';
13
- import { blue, gray, green, red, yellow } from './functions/colors.js';
14
- import {
15
- nodeModulesDir,
16
- scriptsDir,
17
- testDir,
18
- } from './functions/directories.js';
19
- import { syncFolders } from './functions/sync-folders.js';
20
-
21
- // .............................................................................
22
- async function _copyGoldens(srcDir) {
23
- const from = path.join(srcDir, 'goldens');
24
- const to = path.join(testDir, 'goldens', 'io-conformance');
25
- if (!existsSync(to)) {
26
- await fs.mkdir(to, { recursive: true });
27
- }
28
-
29
- console.log(gray(`cp -r ${from} ${to}`));
30
- await syncFolders(from, to, { excludeHidden: true });
31
- }
32
-
33
- // .............................................................................
34
- async function _copyConformanceTests(srcDir) {
35
- const from = path.join(srcDir, 'io-conformance.spec.ts');
36
- const to = path.join(testDir, 'io-conformance.spec.ts');
37
- console.log(gray(`cp ${from} ${to}`));
38
- await fs.copyFile(from, to);
39
- }
40
-
41
- // .............................................................................
42
- async function _srcDir() {
43
- const targetDir = path.join(
44
- nodeModulesDir,
45
- '@rljson',
46
- 'io',
47
- 'dist',
48
- 'conformance-tests',
49
- );
50
- if (!existsSync(targetDir)) {
51
- await fs.mkdir(targetDir, { recursive: true });
52
- }
53
- return targetDir;
54
- }
55
-
56
- // .............................................................................
57
- async function _copyInstallScript(srcDir) {
58
- const from = path.join(srcDir, 'scripts', 'install-conformance-tests.js');
59
- const to = path.join(scriptsDir, 'install-conformance-tests.js');
60
- console.log(gray(`cp ${from} ${to}`));
61
- await fs.copyFile(from, to);
62
- }
63
-
64
- // .............................................................................
65
- async function _copySetupScript(srcDir) {
66
- const from = path.join(srcDir, 'io-conformance.setup.ts');
67
- const to = path.join(testDir, 'io-conformance.setup.ts');
68
-
69
- // Only setup file if not exists
70
- if (existsSync(to)) {
71
- return;
72
- }
73
-
74
- // Update exports of Io, IoTestSetup and IoTools
75
- console.log(gray(`cp ${from} ${to}`));
76
- await fs.copyFile(from, to);
77
-
78
- console.log(
79
- [
80
- yellow('Please open'),
81
- blue('test/io-conformance.setup.ts'),
82
- yellow('and modify'),
83
- green('MyIoTestSetup'),
84
- yellow('to instantiate your Io implementation.'),
85
- ].join(' '),
86
- );
87
- }
88
-
89
- // .............................................................................
90
- try {
91
- // Create target directory if it doesn't exist
92
- console.log(blue('Update conformance tests...'));
93
- const srcDir = await _srcDir();
94
- await _copyConformanceTests(srcDir);
95
- await _copyGoldens(srcDir);
96
- await _copyInstallScript(srcDir);
97
- await _copySetupScript(srcDir);
98
- } catch (err) {
99
- console.error(
100
- red('❌ Error while deploying conformance tests:', err.message),
101
- );
102
- process.exit(1);
103
- }
1
+ /*
2
+ * @license
3
+ * Copyright (c) 2025 Rljson
4
+ *
5
+ * Use of this source code is governed by terms that can be
6
+ * found in the LICENSE file in the root of this package.
7
+ */
8
+
9
+ // Create a folder dist/conformance-tests if it does not exist
10
+ import { existsSync } from 'fs';
11
+ import fs from 'fs/promises';
12
+ import path from 'path';
13
+ import { blue, gray, green, red, yellow } from './functions/colors.js';
14
+ import {
15
+ nodeModulesDir,
16
+ scriptsDir,
17
+ testDir,
18
+ } from './functions/directories.js';
19
+ import { syncFolders } from './functions/sync-folders.js';
20
+
21
+ // .............................................................................
22
+ async function _copyGoldens(srcDir) {
23
+ const from = path.join(srcDir, 'goldens');
24
+ const to = path.join(testDir, 'goldens', 'io-conformance');
25
+ if (!existsSync(to)) {
26
+ await fs.mkdir(to, { recursive: true });
27
+ }
28
+
29
+ console.log(gray(`cp -r ${from} ${to}`));
30
+ await syncFolders(from, to, { excludeHidden: true });
31
+ }
32
+
33
+ // .............................................................................
34
+ async function _copyConformanceTests(srcDir) {
35
+ const from = path.join(srcDir, 'io-conformance.spec.ts');
36
+ const to = path.join(testDir, 'io-conformance.spec.ts');
37
+ console.log(gray(`cp ${from} ${to}`));
38
+ await fs.copyFile(from, to);
39
+ }
40
+
41
+ // .............................................................................
42
+ async function _srcDir() {
43
+ const targetDir = path.join(
44
+ nodeModulesDir,
45
+ '@rljson',
46
+ 'io',
47
+ 'dist',
48
+ 'conformance-tests',
49
+ );
50
+ if (!existsSync(targetDir)) {
51
+ await fs.mkdir(targetDir, { recursive: true });
52
+ }
53
+ return targetDir;
54
+ }
55
+
56
+ // .............................................................................
57
+ async function _copyInstallScript(srcDir) {
58
+ const from = path.join(srcDir, 'scripts', 'install-conformance-tests.js');
59
+ const to = path.join(scriptsDir, 'install-conformance-tests.js');
60
+ console.log(gray(`cp ${from} ${to}`));
61
+ await fs.copyFile(from, to);
62
+ }
63
+
64
+ // .............................................................................
65
+ async function _copySetupScript(srcDir) {
66
+ const from = path.join(srcDir, 'io-conformance.setup.ts');
67
+ const to = path.join(testDir, 'io-conformance.setup.ts');
68
+
69
+ // Only setup file if not exists
70
+ if (existsSync(to)) {
71
+ return;
72
+ }
73
+
74
+ // Update exports of Io, IoTestSetup and IoTools
75
+ console.log(gray(`cp ${from} ${to}`));
76
+ await fs.copyFile(from, to);
77
+
78
+ console.log(
79
+ [
80
+ yellow('Please open'),
81
+ blue('test/io-conformance.setup.ts'),
82
+ yellow('and modify'),
83
+ green('MyIoTestSetup'),
84
+ yellow('to instantiate your Io implementation.'),
85
+ ].join(' '),
86
+ );
87
+ }
88
+
89
+ // .............................................................................
90
+ try {
91
+ // Create target directory if it doesn't exist
92
+ console.log(blue('Update conformance tests...'));
93
+ const srcDir = await _srcDir();
94
+ await _copyConformanceTests(srcDir);
95
+ await _copyGoldens(srcDir);
96
+ await _copyInstallScript(srcDir);
97
+ await _copySetupScript(srcDir);
98
+ } catch (err) {
99
+ console.error(
100
+ red('❌ Error while deploying conformance tests:', err.message),
101
+ );
102
+ process.exit(1);
103
+ }