@jetshop/intl 6.2.0-alpha.31bdc3f3 → 6.2.0-alpha.41c809d5
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/bin/extract-ts.js +51 -0
- package/bin/extract.js +0 -3
- package/bin/intl.js +4 -1
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const program = require('format-message-cli');
|
|
7
|
+
const spawn = require('react-dev-utils/crossSpawn');
|
|
8
|
+
|
|
9
|
+
const tsconfigPath = path.join(process.cwd(), 'tsconfig.json');
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const tscProcess = spawn.sync('tsc', ['-p', tsconfigPath]);
|
|
13
|
+
|
|
14
|
+
if (tscProcess.status !== 0) {
|
|
15
|
+
console.error(
|
|
16
|
+
'\x1b[31m%s\x1b[0m \x1b[33m%s\x1b[0m',
|
|
17
|
+
`TypeScript compilation failed with code ${tscProcess.status}, skipping ...`,
|
|
18
|
+
'\nThis may be due to TypeScript errors in your project, try running `tsc` by itself.'
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.error(e);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));
|
|
28
|
+
const outDir = tsconfig.compilerOptions.outDir;
|
|
29
|
+
|
|
30
|
+
program.parse(
|
|
31
|
+
process.argv
|
|
32
|
+
.slice(0, 2)
|
|
33
|
+
.concat([
|
|
34
|
+
'extract',
|
|
35
|
+
`${outDir}/**/*.js`,
|
|
36
|
+
'node_modules/@jetshop/ui/**/*.js',
|
|
37
|
+
'node_modules/@jetshop/core/**/*.js',
|
|
38
|
+
'../ui/**/*.js',
|
|
39
|
+
'../core/**/*.js',
|
|
40
|
+
'-g',
|
|
41
|
+
'underscored_crc32',
|
|
42
|
+
'-o',
|
|
43
|
+
'translations/default.json'
|
|
44
|
+
])
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
fs.rmSync(outDir, { recursive: true });
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.error(e);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
package/bin/extract.js
CHANGED
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
3
3
|
|
|
4
4
|
const program = require('format-message-cli');
|
|
5
|
-
// TODO: Support typescript
|
|
6
5
|
program.parse(
|
|
7
6
|
process.argv
|
|
8
7
|
.slice(0, 2)
|
|
9
8
|
.concat([
|
|
10
9
|
'extract',
|
|
11
10
|
'src/**/*.js',
|
|
12
|
-
'src/**/*.ts',
|
|
13
|
-
'src/**/*.tsx',
|
|
14
11
|
'node_modules/@jetshop/ui/**/*.js',
|
|
15
12
|
'node_modules/@jetshop/core/**/*.js',
|
|
16
13
|
'../ui/**/*.js',
|
package/bin/intl.js
CHANGED
|
@@ -8,11 +8,14 @@ require('@jetshop/react-scripts/config/env');
|
|
|
8
8
|
const spawn = require('react-dev-utils/crossSpawn');
|
|
9
9
|
const args = process.argv.slice(2);
|
|
10
10
|
|
|
11
|
-
const scriptIndex = args.findIndex(
|
|
11
|
+
const scriptIndex = args.findIndex(
|
|
12
|
+
(x) => x === 'extract-ts' || x === 'extract' || x === 'lint'
|
|
13
|
+
);
|
|
12
14
|
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
|
|
13
15
|
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
|
|
14
16
|
|
|
15
17
|
switch (script) {
|
|
18
|
+
case 'extract-ts':
|
|
16
19
|
case 'extract':
|
|
17
20
|
case 'lint': {
|
|
18
21
|
const result = spawn.sync(
|