@akinon/projectzero 1.13.0 → 1.14.0

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/.prettierrc CHANGED
@@ -1,12 +1,12 @@
1
- {
2
- "bracketSameLine": false,
3
- "tabWidth": 2,
4
- "singleQuote": true,
5
- "bracketSpacing": true,
6
- "semi": true,
7
- "useTabs": false,
8
- "arrowParens": "always",
9
- "endOfLine": "lf",
10
- "proseWrap": "never",
11
- "trailingComma": "none"
12
- }
1
+ {
2
+ "bracketSameLine": false,
3
+ "tabWidth": 2,
4
+ "singleQuote": true,
5
+ "bracketSpacing": true,
6
+ "semi": true,
7
+ "useTabs": false,
8
+ "arrowParens": "always",
9
+ "endOfLine": "lf",
10
+ "proseWrap": "never",
11
+ "trailingComma": "none"
12
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @akinon/projectzero
2
2
 
3
+ ## 1.14.0
4
+
5
+ ## 1.13.1
6
+
3
7
  ## 1.13.0
4
8
 
5
9
  ## 1.12.0
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
- # Project Zero CLI
2
-
3
- This is the command line interface for Project Zero Next.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install -g @akinon/projectzero
9
- ```
10
-
11
- ## Available Commands
12
-
13
- ### `create`
14
- It creates a new project.
15
-
16
- ```bash
17
- npx @akinon/projectzero --create
1
+ # Project Zero CLI
2
+
3
+ This is the command line interface for Project Zero Next.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @akinon/projectzero
9
+ ```
10
+
11
+ ## Available Commands
12
+
13
+ ### `create`
14
+ It creates a new project.
15
+
16
+ ```bash
17
+ npx @akinon/projectzero --create
18
18
  ```
@@ -1,111 +1,111 @@
1
- #!/usr/bin/env node
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
- const argv = require("yargs").argv;
6
-
7
- export default () => {
8
- /**
9
- * @param {string} src The path to the thing to copy.
10
- * @param {string} dest The path to the new copy.
11
- * @param {string} lng Get Language
12
- */
13
- const addLanguage = (src: string, dest: string, lng: string) => {
14
- const exists = fs.existsSync(src);
15
- const stats = exists && fs.statSync(src);
16
- const isDirectory = exists && stats.isDirectory();
17
- if (isDirectory) {
18
- fs.mkdirSync(dest);
19
- fs.readdirSync(src).forEach((childItemName: string) => {
20
- addLanguage(
21
- path.join(src, childItemName),
22
- path.join(dest, childItemName),
23
- lng
24
- );
25
- });
26
-
27
- console.log(
28
- "\x1b[32m%s\x1b[0m",
29
- `\n✓ Added language option ${lng.toUpperCase()}.\nDon't forget to translate '${lng.toUpperCase()}' translation files inside 'public/locales/${lng.toUpperCase()}'\n`
30
- );
31
-
32
- console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
33
- } else {
34
- fs.copyFileSync(src, dest);
35
- }
36
- };
37
-
38
- const i18nDocumentUpdate = (lng: string) => {
39
- /* next-i18next.config.js */
40
- const workingDir = path.resolve(process.cwd());
41
-
42
- const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
43
-
44
- if (!fs.existsSync(i18nPath)) {
45
- return;
46
- }
47
-
48
- const i18nData = fs.readFileSync(i18nPath, {
49
- encoding: "utf8",
50
- flag: "r",
51
- });
52
-
53
- fs.writeFileSync(
54
- i18nPath,
55
- i18nData.replace(/locales: '*.'/, `locales: ['${lng}', '`)
56
- );
57
-
58
- /* settings.js */
59
-
60
- const settingsPath = path.resolve(workingDir, "src/settings.js");
61
-
62
- if (!fs.existsSync(settingsPath)) {
63
- return;
64
- }
65
-
66
- const settingsData = fs.readFileSync(settingsPath, {
67
- encoding: "utf8",
68
- flag: "r",
69
- });
70
-
71
- const data = `{ label: '${lng.toUpperCase()}', value: '${lng.toLowerCase()}', apiValue: '${
72
- argv.addLanguage
73
- }' }`;
74
-
75
- const changes = "languages: [";
76
-
77
- fs.writeFileSync(
78
- settingsPath,
79
- settingsData.replace(changes, `languages: [\n\t\t${data},`)
80
- );
81
- };
82
-
83
- const init = () => {
84
- if (!argv.addLanguage) return;
85
- let lng = argv.addLanguage;
86
- lng = lng.split("-")[0];
87
-
88
- const dest = `public/locales/${lng}`;
89
- const exists = fs.existsSync(dest);
90
-
91
- try {
92
- if (exists)
93
- throw new Error(`${lng.toUpperCase()} has already been added`);
94
- addLanguage("public/locales/en", `public/locales/${lng}`, lng);
95
- i18nDocumentUpdate(lng);
96
- } catch (err) {
97
- const typedError = err as Error;
98
-
99
- console.log(
100
- "\n\x1b[31m%s\x1b[0m",
101
- `${
102
- typedError.message
103
- ? typedError.message + "\n"
104
- : "Something went wrong.\n"
105
- }`
106
- );
107
- }
108
- };
109
-
110
- init();
111
- };
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const argv = require("yargs").argv;
6
+
7
+ export default () => {
8
+ /**
9
+ * @param {string} src The path to the thing to copy.
10
+ * @param {string} dest The path to the new copy.
11
+ * @param {string} lng Get Language
12
+ */
13
+ const addLanguage = (src: string, dest: string, lng: string) => {
14
+ const exists = fs.existsSync(src);
15
+ const stats = exists && fs.statSync(src);
16
+ const isDirectory = exists && stats.isDirectory();
17
+ if (isDirectory) {
18
+ fs.mkdirSync(dest);
19
+ fs.readdirSync(src).forEach((childItemName: string) => {
20
+ addLanguage(
21
+ path.join(src, childItemName),
22
+ path.join(dest, childItemName),
23
+ lng
24
+ );
25
+ });
26
+
27
+ console.log(
28
+ "\x1b[32m%s\x1b[0m",
29
+ `\n✓ Added language option ${lng.toUpperCase()}.\nDon't forget to translate '${lng.toUpperCase()}' translation files inside 'public/locales/${lng.toUpperCase()}'\n`
30
+ );
31
+
32
+ console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
33
+ } else {
34
+ fs.copyFileSync(src, dest);
35
+ }
36
+ };
37
+
38
+ const i18nDocumentUpdate = (lng: string) => {
39
+ /* next-i18next.config.js */
40
+ const workingDir = path.resolve(process.cwd());
41
+
42
+ const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
43
+
44
+ if (!fs.existsSync(i18nPath)) {
45
+ return;
46
+ }
47
+
48
+ const i18nData = fs.readFileSync(i18nPath, {
49
+ encoding: "utf8",
50
+ flag: "r",
51
+ });
52
+
53
+ fs.writeFileSync(
54
+ i18nPath,
55
+ i18nData.replace(/locales: '*.'/, `locales: ['${lng}', '`)
56
+ );
57
+
58
+ /* settings.js */
59
+
60
+ const settingsPath = path.resolve(workingDir, "src/settings.js");
61
+
62
+ if (!fs.existsSync(settingsPath)) {
63
+ return;
64
+ }
65
+
66
+ const settingsData = fs.readFileSync(settingsPath, {
67
+ encoding: "utf8",
68
+ flag: "r",
69
+ });
70
+
71
+ const data = `{ label: '${lng.toUpperCase()}', value: '${lng.toLowerCase()}', apiValue: '${
72
+ argv.addLanguage
73
+ }' }`;
74
+
75
+ const changes = "languages: [";
76
+
77
+ fs.writeFileSync(
78
+ settingsPath,
79
+ settingsData.replace(changes, `languages: [\n\t\t${data},`)
80
+ );
81
+ };
82
+
83
+ const init = () => {
84
+ if (!argv.addLanguage) return;
85
+ let lng = argv.addLanguage;
86
+ lng = lng.split("-")[0];
87
+
88
+ const dest = `public/locales/${lng}`;
89
+ const exists = fs.existsSync(dest);
90
+
91
+ try {
92
+ if (exists)
93
+ throw new Error(`${lng.toUpperCase()} has already been added`);
94
+ addLanguage("public/locales/en", `public/locales/${lng}`, lng);
95
+ i18nDocumentUpdate(lng);
96
+ } catch (err) {
97
+ const typedError = err as Error;
98
+
99
+ console.log(
100
+ "\n\x1b[31m%s\x1b[0m",
101
+ `${
102
+ typedError.message
103
+ ? typedError.message + "\n"
104
+ : "Something went wrong.\n"
105
+ }`
106
+ );
107
+ }
108
+ };
109
+
110
+ init();
111
+ };
@@ -1,33 +1,33 @@
1
- import * as fs from 'fs';
2
- import path from 'path';
3
-
4
- const yargs = require('yargs/yargs');
5
- const { hideBin } = require('yargs/helpers');
6
- const args = yargs(hideBin(process.argv)).argv;
7
-
8
- export default () => {
9
- const workingDir = path.resolve(process.cwd());
10
- const settingsPath = path.resolve(workingDir, './src/settings.js');
11
-
12
- if (!fs.existsSync(settingsPath)) {
13
- return;
14
- }
15
-
16
- const settingsData = fs.readFileSync(settingsPath, {
17
- encoding: 'utf8',
18
- flag: 'r'
19
- });
20
-
21
- fs.writeFileSync(
22
- settingsPath,
23
- settingsData.replace(
24
- /commerceUrl: '.*'/,
25
- `commerceUrl: '${args.commerceUrl}'`
26
- )
27
- );
28
-
29
- console.log(
30
- '\x1b[32m%s\x1b[0m',
31
- `\n ✓ Commerce URL is set to ${args.commerceUrl}.\n\n`
32
- );
33
- };
1
+ import * as fs from 'fs';
2
+ import path from 'path';
3
+
4
+ const yargs = require('yargs/yargs');
5
+ const { hideBin } = require('yargs/helpers');
6
+ const args = yargs(hideBin(process.argv)).argv;
7
+
8
+ export default () => {
9
+ const workingDir = path.resolve(process.cwd());
10
+ const settingsPath = path.resolve(workingDir, './src/settings.js');
11
+
12
+ if (!fs.existsSync(settingsPath)) {
13
+ return;
14
+ }
15
+
16
+ const settingsData = fs.readFileSync(settingsPath, {
17
+ encoding: 'utf8',
18
+ flag: 'r'
19
+ });
20
+
21
+ fs.writeFileSync(
22
+ settingsPath,
23
+ settingsData.replace(
24
+ /commerceUrl: '.*'/,
25
+ `commerceUrl: '${args.commerceUrl}'`
26
+ )
27
+ );
28
+
29
+ console.log(
30
+ '\x1b[32m%s\x1b[0m',
31
+ `\n ✓ Commerce URL is set to ${args.commerceUrl}.\n\n`
32
+ );
33
+ };