@jetshop/intl 6.1.4 → 6.1.5

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.
@@ -0,0 +1,69 @@
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
+ if (!fs.existsSync(tsconfigPath)) {
12
+ console.error('No tsconfig.json found.');
13
+ process.exit(1);
14
+ }
15
+
16
+ try {
17
+ const tscProcess = spawn.sync('tsc', ['-p', tsconfigPath]);
18
+
19
+ if (tscProcess.status !== 0) {
20
+ console.error(
21
+ '\x1b[31m%s\x1b[0m \x1b[33m%s\x1b[0m',
22
+ `TypeScript compilation failed with code ${tscProcess.status}, skipping ...`,
23
+ '\nThis may be due to TypeScript errors in your project, try running `tsc` by itself.'
24
+ );
25
+ }
26
+ } catch (e) {
27
+ console.error(e);
28
+ process.exit(1);
29
+ }
30
+
31
+ try {
32
+ const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));
33
+ const outDir = tsconfig?.compilerOptions?.outDir;
34
+ const noEmit = tsconfig?.compilerOptions?.noEmit;
35
+
36
+ if (!outDir) {
37
+ console.error(`\n outDir property required. \n`);
38
+ process.exit(1);
39
+ }
40
+
41
+ if (noEmit) {
42
+ console.error(
43
+ `\n This command requires files to be emitted. Make sure the noEmit property is set to false. \n`
44
+ );
45
+ process.exit(1);
46
+ }
47
+
48
+ program.parse(
49
+ process.argv
50
+ .slice(0, 2)
51
+ .concat([
52
+ 'extract',
53
+ `${outDir}/**/*.js`,
54
+ 'node_modules/@jetshop/ui/**/*.js',
55
+ 'node_modules/@jetshop/core/**/*.js',
56
+ '../ui/**/*.js',
57
+ '../core/**/*.js',
58
+ '-g',
59
+ 'underscored_crc32',
60
+ '-o',
61
+ 'translations/default.json'
62
+ ])
63
+ );
64
+
65
+ fs.rmSync(outDir, { recursive: true });
66
+ } catch (e) {
67
+ console.error(e);
68
+ process.exit(1);
69
+ }
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(x => x === 'extract' || x === 'lint');
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(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetshop/intl",
3
- "version": "6.1.4",
3
+ "version": "6.1.5",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "bin": {