@akinon/projectzero 1.0.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.
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const argv = require("yargs").argv;
7
+ exports.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, dest, lng) => {
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) => {
20
+ addLanguage(path.join(src, childItemName), path.join(dest, childItemName), lng);
21
+ });
22
+ console.log("\x1b[32m%s\x1b[0m", `\n✓ Added language option ${lng.toUpperCase()}.\nDon't forget to translate '${lng.toUpperCase()}' translation files inside 'public/locales/${lng.toUpperCase()}'\n`);
23
+ console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
24
+ }
25
+ else {
26
+ fs.copyFileSync(src, dest);
27
+ }
28
+ };
29
+ const i18nDocumentUpdate = (lng) => {
30
+ /* next-i18next.config.js */
31
+ const workingDir = path.resolve(process.cwd());
32
+ const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
33
+ if (!fs.existsSync(i18nPath)) {
34
+ return;
35
+ }
36
+ const i18nData = fs.readFileSync(i18nPath, {
37
+ encoding: "utf8",
38
+ flag: "r",
39
+ });
40
+ fs.writeFileSync(i18nPath, i18nData.replace(/locales: '*.'/, `locales: ['${lng}', '`));
41
+ /* settings.js */
42
+ const settingsPath = path.resolve(workingDir, "src/settings.js");
43
+ if (!fs.existsSync(settingsPath)) {
44
+ return;
45
+ }
46
+ const settingsData = fs.readFileSync(settingsPath, {
47
+ encoding: "utf8",
48
+ flag: "r",
49
+ });
50
+ const data = `{ label: '${lng.toUpperCase()}', value: '${lng.toLowerCase()}', apiValue: '${argv.addLanguage}' }`;
51
+ const changes = "languages: [";
52
+ fs.writeFileSync(settingsPath, settingsData.replace(changes, `languages: [\n\t\t${data},`));
53
+ };
54
+ const init = () => {
55
+ if (!argv.addLanguage)
56
+ return;
57
+ let lng = argv.addLanguage;
58
+ lng = lng.split("-")[0];
59
+ const dest = `public/locales/${lng}`;
60
+ const exists = fs.existsSync(dest);
61
+ try {
62
+ if (exists)
63
+ throw new Error(`${lng.toUpperCase()} has already been added`);
64
+ addLanguage("public/locales/en", `public/locales/${lng}`, lng);
65
+ i18nDocumentUpdate(lng);
66
+ }
67
+ catch (err) {
68
+ const typedError = err;
69
+ console.log("\n\x1b[31m%s\x1b[0m", `${typedError.message
70
+ ? typedError.message + "\n"
71
+ : "Something went wrong.\n"}`);
72
+ }
73
+ };
74
+ init();
75
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const fs = __importStar(require("fs"));
30
+ const path_1 = __importDefault(require("path"));
31
+ const yargs = require('yargs/yargs');
32
+ const { hideBin } = require('yargs/helpers');
33
+ const args = yargs(hideBin(process.argv)).argv;
34
+ exports.default = () => {
35
+ const workingDir = path_1.default.resolve(process.cwd());
36
+ const settingsPath = path_1.default.resolve(workingDir, './src/settings.js');
37
+ if (!fs.existsSync(settingsPath)) {
38
+ return;
39
+ }
40
+ const settingsData = fs.readFileSync(settingsPath, {
41
+ encoding: 'utf8',
42
+ flag: 'r'
43
+ });
44
+ fs.writeFileSync(settingsPath, settingsData.replace(/commerceUrl: '.*'/, `commerceUrl: '${args.commerceUrl}'`));
45
+ console.log('\x1b[32m%s\x1b[0m', `\n ✓ Commerce URL is set to ${args.commerceUrl}.\n\n`);
46
+ };
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const path_1 = __importDefault(require("path"));
39
+ const fs = __importStar(require("fs"));
40
+ const readline = __importStar(require("readline"));
41
+ const utils_1 = require("../utils");
42
+ const child_process_1 = require("child_process");
43
+ const exec = require('child_process').exec;
44
+ const loadingSpinner = require('loading-spinner');
45
+ const repositorySlug = 'projectzeropwa';
46
+ const tempDirName = '.pz-temp';
47
+ const workingDir = path_1.default.resolve(process.cwd());
48
+ const rl = readline.createInterface({
49
+ input: process.stdin,
50
+ output: process.stdout
51
+ });
52
+ const ANSWERS = {};
53
+ const QUESTIONS = [
54
+ {
55
+ text: 'Brand name',
56
+ optional: false,
57
+ answerKey: 'brandName',
58
+ hint: 'eg. Project Zero'
59
+ },
60
+ {
61
+ text: 'Project description',
62
+ optional: true,
63
+ answerKey: 'projectDescription'
64
+ },
65
+ {
66
+ text: 'Commerce URL (SERVICE_BACKEND_URL)',
67
+ optional: true,
68
+ answerKey: 'commerceUrl',
69
+ hint: 'Can be changed later'
70
+ }
71
+ ];
72
+ const getAnswers = () => {
73
+ return new Promise((resolve) => {
74
+ const question = QUESTIONS[Object.keys(ANSWERS).length];
75
+ if (!question) {
76
+ rl.close();
77
+ resolve(ANSWERS);
78
+ return;
79
+ }
80
+ let questionText = question.text;
81
+ if (question.hint) {
82
+ questionText += ` (${question.hint})`;
83
+ }
84
+ if (question.optional) {
85
+ questionText += ` (optional)`;
86
+ }
87
+ rl.question(`${questionText}: `, (answer) => {
88
+ if (!question.optional && !answer.length) {
89
+ console.log('\x1b[31m%s\x1b[0m', `* This field is required\n`);
90
+ resolve(getAnswers());
91
+ }
92
+ else {
93
+ ANSWERS[question.answerKey] = answer;
94
+ resolve(getAnswers());
95
+ }
96
+ });
97
+ });
98
+ };
99
+ const cloneRepository = () => new Promise((resolve) => {
100
+ (0, child_process_1.execSync)(`mkdir ${tempDirName}`);
101
+ exec(`cd ${tempDirName} && git clone git@bitbucket.org:akinonteam/${repositorySlug}.git`, function (err, stdout, stderr) {
102
+ if (err != null) {
103
+ resolve({ error: new Error(err) });
104
+ }
105
+ else if (typeof stderr != 'string') {
106
+ resolve({ error: new Error(stderr) });
107
+ }
108
+ else {
109
+ resolve({});
110
+ }
111
+ });
112
+ });
113
+ const updatePackageJson = (brandName) => {
114
+ const packageJsonPath = path_1.default.resolve(workingDir, `./${tempDirName}/${repositorySlug}/package.json`);
115
+ const packageJsonData = fs.readFileSync(packageJsonPath, {
116
+ encoding: 'utf8',
117
+ flag: 'r'
118
+ });
119
+ fs.writeFileSync(packageJsonPath, packageJsonData.replace(/"name": ".*"/, `"name": "${(0, utils_1.slugify)(brandName)}"`));
120
+ };
121
+ const updateAkinonJson = (brandName, projectDescription) => {
122
+ const akinonJsonPath = path_1.default.resolve(workingDir, `./${tempDirName}/${repositorySlug}/akinon.json`);
123
+ const akinonJsonData = fs.readFileSync(akinonJsonPath, {
124
+ encoding: 'utf8',
125
+ flag: 'r'
126
+ });
127
+ let updatedData = akinonJsonData.replace(/"name": ".*"/, `"name": "${brandName}"`);
128
+ if (projectDescription) {
129
+ updatedData = updatedData.replace(/"description": ".*"/, `"description": "${projectDescription}"`);
130
+ }
131
+ fs.writeFileSync(akinonJsonPath, updatedData);
132
+ };
133
+ const copyEnv = (commerceUrl) => {
134
+ const repositoryPath = path_1.default.resolve(workingDir, `./${tempDirName}/${repositorySlug}`);
135
+ const envExamplePath = path_1.default.resolve(repositoryPath, `./.env.example`);
136
+ const envPath = path_1.default.resolve(repositoryPath, `./.env`);
137
+ const envData = fs.readFileSync(envExamplePath, {
138
+ encoding: 'utf8',
139
+ flag: 'r'
140
+ });
141
+ if (commerceUrl) {
142
+ fs.writeFileSync(envExamplePath, envData.replace(/SERVICE_BACKEND_URL=.*/, `SERVICE_BACKEND_URL=${commerceUrl}`));
143
+ }
144
+ fs.copyFileSync(envExamplePath, envPath);
145
+ };
146
+ const updatePlugins = () => {
147
+ const pluginsPath = path_1.default.resolve(workingDir, `./${tempDirName}/${repositorySlug}/src/plugins.js`);
148
+ fs.writeFileSync(pluginsPath, 'module.exports = [];');
149
+ };
150
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
151
+ const answers = yield getAnswers();
152
+ loadingSpinner.start();
153
+ yield cloneRepository();
154
+ updatePackageJson(answers.brandName);
155
+ updateAkinonJson(answers.brandName, answers.projectDescription);
156
+ copyEnv(answers.commerceUrl);
157
+ updatePlugins();
158
+ const slugifiedBrandName = (0, utils_1.slugify)(answers.brandName);
159
+ fs.rmSync(path_1.default.resolve(workingDir, `./${tempDirName}/${repositorySlug}/.git`), {
160
+ recursive: true,
161
+ force: true
162
+ });
163
+ fs.renameSync(path_1.default.resolve(workingDir, `./${tempDirName}/${repositorySlug}`), path_1.default.resolve(workingDir, `./${tempDirName}/${slugifiedBrandName}`));
164
+ fs.cpSync(path_1.default.resolve(workingDir, `./${tempDirName}/${slugifiedBrandName}`), path_1.default.resolve(workingDir, `./${slugifiedBrandName}`), {
165
+ recursive: true,
166
+ force: true
167
+ });
168
+ fs.rmSync(path_1.default.resolve(workingDir, `./${tempDirName}/`), {
169
+ recursive: true,
170
+ force: true
171
+ });
172
+ loadingSpinner.stop();
173
+ console.log('\x1b[32m%s\x1b[0m', `\n ✓ ${answers.brandName} project is ready.\n`);
174
+ console.log('\x1b[33m%s\x1b[0m', 'Project Zero - Akinon\n');
175
+ });
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const argv = require("yargs").argv;
7
+ exports.default = () => {
8
+ const i18nDocumentUpdate = (lng) => {
9
+ /* next-i18next.config.js */
10
+ const workingDir = path.resolve(process.cwd());
11
+ const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
12
+ if (!fs.existsSync(i18nPath)) {
13
+ return;
14
+ }
15
+ const i18nData = fs.readFileSync(i18nPath, {
16
+ encoding: "utf8",
17
+ flag: "r",
18
+ });
19
+ const regExpLiteral = "locales:(.+)+";
20
+ const result = i18nData.match(regExpLiteral);
21
+ if (result[1].search(lng) < 0) {
22
+ throw new Error(`${lng.toUpperCase()} not available`);
23
+ }
24
+ let updatedData = i18nData.replace(/defaultLocale: '.*'/, `defaultLocale: '${lng}'`);
25
+ updatedData = updatedData.replace(/fallbackLng: '.*'/, `fallbackLng: '${lng}'`);
26
+ fs.writeFileSync(i18nPath, updatedData);
27
+ };
28
+ const init = () => {
29
+ if (!argv.defaultLanguage)
30
+ return;
31
+ let lng = argv.defaultLanguage;
32
+ try {
33
+ i18nDocumentUpdate(lng);
34
+ console.log("\x1b[32m%s\x1b[0m", `\n✓ Set as the default language option ${lng.toUpperCase()}.\n`);
35
+ console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
36
+ }
37
+ catch (err) {
38
+ const typedError = err;
39
+ console.log("\n\x1b[31m%s\x1b[0m", `${typedError.message
40
+ ? typedError.message + "\n"
41
+ : "Something went wrong.\n"}`);
42
+ }
43
+ };
44
+ init();
45
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const commerce_url_1 = __importDefault(require("./commerce-url"));
7
+ const create_1 = __importDefault(require("./create"));
8
+ const add_language_1 = __importDefault(require("./add-language"));
9
+ const remove_language_1 = __importDefault(require("./remove-language"));
10
+ const default_language_1 = __importDefault(require("./default-language"));
11
+ const plugins_1 = __importDefault(require("./plugins"));
12
+ exports.default = {
13
+ commerceUrl: commerce_url_1.default,
14
+ create: create_1.default,
15
+ addLanguage: add_language_1.default,
16
+ removeLanguage: remove_language_1.default,
17
+ defaultLanguage: default_language_1.default,
18
+ plugins: plugins_1.default
19
+ };
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const fs = __importStar(require("fs"));
39
+ const path_1 = __importDefault(require("path"));
40
+ const child_process_1 = require("child_process");
41
+ const Prompt = require('prompt-checkbox');
42
+ const rootDir = path_1.default.resolve(process.cwd());
43
+ const pluginsFilePath = path_1.default.resolve(rootDir, './src/plugins.js');
44
+ let installedPlugins = [];
45
+ try {
46
+ installedPlugins = require(path_1.default.resolve(rootDir, './src/plugins.js'));
47
+ }
48
+ catch (error) { }
49
+ const definedPlugins = [
50
+ {
51
+ name: 'Basket Gift Pack',
52
+ value: 'pz-basket-gift-package'
53
+ }
54
+ ];
55
+ exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
56
+ const prompt = new Prompt({
57
+ name: 'plugins',
58
+ message: 'Please check/uncheck plugins to install/uninstall.',
59
+ type: 'checkbox',
60
+ default: installedPlugins.map((p) => definedPlugins.findIndex((dp) => dp.value === p)),
61
+ choices: definedPlugins.map((p, index) => `${index + 1}) ${p.name}`)
62
+ });
63
+ prompt.ask((answers) => __awaiter(void 0, void 0, void 0, function* () {
64
+ const formattedAnswers = answers.map((answer) => answer.replace(/\d\)\s/, ''));
65
+ const values = formattedAnswers.map((answer) => { var _a; return (_a = definedPlugins.find((p) => p.name === answer)) === null || _a === void 0 ? void 0 : _a.value; });
66
+ if (formattedAnswers.length) {
67
+ console.log(`\nInstalling ${formattedAnswers.join(', ')}.`);
68
+ }
69
+ else {
70
+ console.log(`\nUninstalling all plugins.`);
71
+ }
72
+ console.log(`\nPlease wait...`);
73
+ fs.writeFileSync(pluginsFilePath, `module.exports = ${JSON.stringify(values)};\n`, {
74
+ encoding: 'utf-8'
75
+ });
76
+ (0, child_process_1.execSync)('yarn install', { stdio: 'pipe' });
77
+ console.log('\x1b[32m%s\x1b[0m', `\n ✓ ${formattedAnswers.length
78
+ ? 'Installed selected plugins'
79
+ : 'Uninstalled all plugins'}.\n`);
80
+ }));
81
+ });
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const argv = require("yargs").argv;
7
+ exports.default = () => {
8
+ /**
9
+ * @param {string} lng Get Language
10
+ */
11
+ const removeLanguage = (lng) => {
12
+ const workingDir = path.resolve(process.cwd());
13
+ try {
14
+ fs.rm(`public/locales/${lng}`, { recursive: true }, (err) => {
15
+ if (err) {
16
+ console.error(err);
17
+ return;
18
+ }
19
+ });
20
+ }
21
+ catch (error) {
22
+ console.log("error", error);
23
+ }
24
+ /* settings.js */
25
+ const settingsPath = path.resolve(workingDir, "src/settings.js");
26
+ if (!fs.existsSync(settingsPath)) {
27
+ return;
28
+ }
29
+ const settingsData = fs.readFileSync(settingsPath, {
30
+ encoding: "utf8",
31
+ flag: "r",
32
+ });
33
+ const data = `{ label: '${lng.toUpperCase()}', value: '${lng.toLowerCase()}', apiValue: '${lng.toLowerCase()}-${lng.toLowerCase()}' },`;
34
+ let updatedData = settingsData.replace(data.toString(), "");
35
+ updatedData = updatedData.replace(/^\s*$(?:\r\n?|\n)/gm, "");
36
+ fs.writeFileSync(settingsPath, updatedData);
37
+ /* next-i18next.config.js */
38
+ const i18nPath = path.resolve(workingDir, "next-i18next.config.js");
39
+ if (!fs.existsSync(i18nPath)) {
40
+ return;
41
+ }
42
+ const i18nData = fs.readFileSync(i18nPath, {
43
+ encoding: "utf8",
44
+ flag: "r",
45
+ });
46
+ fs.writeFileSync(i18nPath, i18nData.replace(`'${lng}',\u0020`, ""));
47
+ console.log("\x1b[32m%s\x1b[0m", `\n✓ Remove language option ${lng.toUpperCase()}.\n`);
48
+ console.log("\x1b[33m%s\x1b[0m", "Project Zero - Akinon\n");
49
+ };
50
+ const init = () => {
51
+ if (!argv.removeLanguage)
52
+ return;
53
+ let lng = argv.removeLanguage;
54
+ try {
55
+ removeLanguage(lng);
56
+ }
57
+ catch (err) {
58
+ const typedError = err;
59
+ console.log("\n\x1b[31m%s\x1b[0m", `${typedError.message
60
+ ? typedError.message + "\n"
61
+ : "Something went wrong.\n"}`);
62
+ }
63
+ };
64
+ init();
65
+ };
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ #! /usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const commands_1 = __importDefault(require("./commands"));
8
+ const yargs = require('yargs/yargs');
9
+ const { hideBin } = require('yargs/helpers');
10
+ const args = yargs(hideBin(process.argv)).argv;
11
+ (() => {
12
+ Object.keys(args)
13
+ .filter((arg) => commands_1.default[arg])
14
+ .forEach((arg) => {
15
+ commands_1.default[arg]();
16
+ });
17
+ })();
package/dist/utils.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.slugify = void 0;
4
+ const slugify = (text) => {
5
+ text = text.replace(/^[A-Z]/g, (letter) => letter.toLowerCase());
6
+ text = text.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
7
+ return text
8
+ .toLowerCase()
9
+ .replace(/[\s_]+/g, "-")
10
+ .replace(/[^a-z0-9-_]/g, "");
11
+ };
12
+ exports.slugify = slugify;
package/index.ts ADDED
@@ -0,0 +1,15 @@
1
+ #! /usr/bin/env node
2
+
3
+ import commands from './commands';
4
+
5
+ const yargs = require('yargs/yargs');
6
+ const { hideBin } = require('yargs/helpers');
7
+ const args = yargs(hideBin(process.argv)).argv;
8
+
9
+ (() => {
10
+ Object.keys(args)
11
+ .filter((arg) => (commands as any)[arg])
12
+ .forEach((arg) => {
13
+ (commands as any)[arg]();
14
+ });
15
+ })();
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@akinon/projectzero",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "description": "CLI tool to manage your Project Zero Next project",
6
+ "bin": {
7
+ "projectzero": "dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "clean": "rm -rf node_modules"
12
+ },
13
+ "keywords": [],
14
+ "author": "",
15
+ "license": "ISC",
16
+ "devDependencies": {
17
+ "@types/node": "^18.8.0"
18
+ },
19
+ "dependencies": {
20
+ "loading-spinner": "^1.2.1",
21
+ "yargs": "^17.6.0",
22
+ "prompt-checkbox": "2.2.0"
23
+ }
24
+ }