@elinzy/cli 0.0.0-stage → 0.1.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Appleex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # e-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Introduction
4
+
5
+ `e-cli` is a command line tool. It includes release, publish and changelog commands, and more new functions will be added in the future.
6
+
7
+ ## Installation
8
+
9
+ ```shell
10
+ npm install -D @elinz/e-cli
11
+ ```
12
+
13
+ or, globals
14
+
15
+ ```shell
16
+ npm install -g @elinzy/e-cli
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```shell
22
+ # Just generate changelogs
23
+ npx e changelog
24
+ ```
25
+
26
+ ## Configuration
27
+
28
+ - changelog
29
+
30
+ | Name | Arguments | Type | Default | Description |
31
+ |--------------|-----------------------------------------|--------|------------------|---------------------------------------------------------------------------------------|
32
+ | file | -f --file <file> | string | `CHANGELOG.md` | Specify changelog filename |
33
+ | releaseCount | -n --releaseCount <releaseCount> | number | `0` | Release count |
34
+ | preset | -p --preset <preset> | string | `angular` | Specify changelog preset. Example: `angular, atom, codemirror, conventionalcommits` |
35
+
36
+ ## License
37
+
38
+ [MIT](https://github.com/Appleec/e-cli/blob/main/LICENSE)
39
+
40
+ ## References
41
+
42
+ - [release-it](https://github.com/release-it/release-it)
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ exports.__toESM = __toESM;
@@ -0,0 +1,258 @@
1
+ #!/usr/bin/env node
2
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_functions = require("../utils/functions.cjs");
4
+ const require_common = require("../constants/common.cjs");
5
+ require("../constants/index.cjs");
6
+ const require_index$1 = require("../helpers/createEslintConfigFile/index.cjs");
7
+ const require_index$2 = require("../helpers/getCommands/index.cjs");
8
+ const require_index$3 = require("../helpers/getConfigUrl/index.cjs");
9
+ const require_index$4 = require("../helpers/installPackages/index.cjs");
10
+ let ansis = require("ansis");
11
+ ansis = require_runtime.__toESM(ansis, 1);
12
+ let node_path = require("node:path");
13
+ node_path = require_runtime.__toESM(node_path, 1);
14
+ let prompts = require("prompts");
15
+ prompts = require_runtime.__toESM(prompts, 1);
16
+ //#region src/commands/eslint.ts
17
+ const eslint = async () => {
18
+ process.on("SIGINT", require_functions.handleSigTerm);
19
+ process.on("SIGTERM", require_functions.handleSigTerm);
20
+ let args = {
21
+ config: null,
22
+ language: null,
23
+ formatter: null,
24
+ runtime: null,
25
+ strictConfig: null,
26
+ legacyConfig: null,
27
+ createEslintFile: null,
28
+ skipInstall: null
29
+ };
30
+ if (args.config === null) {
31
+ const { configBoolean } = await (0, prompts.default)({
32
+ type: "toggle",
33
+ name: "configBoolean",
34
+ message: "Config type?",
35
+ initial: require_common.defaults.config === require_common.configs.EXTENDED,
36
+ active: "Extended (flat config)",
37
+ inactive: "Legacy (.eslintrc)",
38
+ onState: require_functions.onPromptState
39
+ }, { onCancel: require_functions.onCancel });
40
+ const config = configBoolean ? require_common.configs.EXTENDED : require_common.configs.LEGACY;
41
+ args = {
42
+ ...args,
43
+ config,
44
+ ...config === require_common.configs.EXTENDED ? { legacyConfig: null } : { runtime: null }
45
+ };
46
+ }
47
+ if (args.language === null) {
48
+ const { languageBoolean } = await (0, prompts.default)({
49
+ type: "toggle",
50
+ name: "languageBoolean",
51
+ message: `Are you using ${ansis.default.blue("TypeScript")}?`,
52
+ initial: require_common.defaults.language === require_common.languages.TYPESCRIPT,
53
+ active: "Yes",
54
+ inactive: "No",
55
+ onState: require_functions.onPromptState
56
+ }, { onCancel: require_functions.onCancel });
57
+ args = {
58
+ ...args,
59
+ language: languageBoolean ? require_common.languages.TYPESCRIPT : require_common.languages.JAVASCRIPT
60
+ };
61
+ }
62
+ if (args.formatter === require_common.formatters.NONE) args = {
63
+ ...args,
64
+ formatter: null
65
+ };
66
+ else if (args.formatter === null) {
67
+ const { formatterBoolean } = await (0, prompts.default)({
68
+ type: "toggle",
69
+ name: "formatterBoolean",
70
+ message: `Are you using ${ansis.default.cyan("Prettier")}?`,
71
+ initial: require_common.defaults.formatter === require_common.formatters.PRETTIER,
72
+ active: "Yes",
73
+ inactive: "No",
74
+ onState: require_functions.onPromptState
75
+ }, { onCancel: require_functions.onCancel });
76
+ args = {
77
+ ...args,
78
+ formatter: formatterBoolean ? require_common.formatters.PRETTIER : null
79
+ };
80
+ }
81
+ if (args.config === require_common.configs.EXTENDED && !args.runtime) {
82
+ const { runtime } = await (0, prompts.default)({
83
+ type: "select",
84
+ name: "runtime",
85
+ message: "Which runtime?",
86
+ choices: [
87
+ {
88
+ title: "Node.js",
89
+ description: ansis.default.green("Node.js backend or library"),
90
+ value: require_common.runtimes.NODE
91
+ },
92
+ {
93
+ title: "React",
94
+ description: ansis.default.cyan("React.js with JSX"),
95
+ value: require_common.runtimes.REACT
96
+ },
97
+ {
98
+ title: "Next.js",
99
+ description: ansis.default.blackBright("Next.js framework"),
100
+ value: require_common.runtimes.NEXT
101
+ }
102
+ ],
103
+ onState: require_functions.onPromptState
104
+ }, { onCancel: require_functions.onCancel });
105
+ args = {
106
+ ...args,
107
+ runtime
108
+ };
109
+ }
110
+ if (args.config === require_common.configs.EXTENDED) {
111
+ if (args.strictConfig?.includes(require_common.strictConfigs.NONE)) args = {
112
+ ...args,
113
+ strictConfig: null
114
+ };
115
+ else if (!args.strictConfig) {
116
+ const { hasStrictConfig } = await (0, prompts.default)({
117
+ type: "toggle",
118
+ name: "hasStrictConfig",
119
+ message: `Add ${ansis.default.yellow("strict")} configs?`,
120
+ initial: require_common.defaults.strictConfig,
121
+ active: "Yes",
122
+ inactive: "No",
123
+ onState: require_functions.onPromptState
124
+ }, { onCancel: require_functions.onCancel });
125
+ if (hasStrictConfig) {
126
+ const { strictConfig } = await (0, prompts.default)({
127
+ type: "multiselect",
128
+ name: "strictConfig",
129
+ message: "Select strict configs:",
130
+ min: 1,
131
+ choices: [
132
+ {
133
+ title: "Import",
134
+ description: ansis.default.yellow("Strict import rules"),
135
+ value: require_common.strictConfigs.IMPORT
136
+ },
137
+ ...args.runtime && [require_common.runtimes.REACT, require_common.runtimes.NEXT].includes(args.runtime) ? [{
138
+ title: "React",
139
+ description: ansis.default.cyan("Strict React rules"),
140
+ value: require_common.strictConfigs.REACT
141
+ }] : [],
142
+ ...args.language === require_common.languages.TYPESCRIPT ? [{
143
+ title: "TypeScript",
144
+ description: ansis.default.blue("Strict TypeScript rules"),
145
+ value: require_common.strictConfigs.TYPESCRIPT
146
+ }] : []
147
+ ],
148
+ onState: require_functions.onPromptState
149
+ }, { onCancel: require_functions.onCancel });
150
+ args = {
151
+ ...args,
152
+ strictConfig
153
+ };
154
+ } else args = {
155
+ ...args,
156
+ strictConfig: null
157
+ };
158
+ }
159
+ }
160
+ if (args.config === require_common.configs.LEGACY && !args.legacyConfig) {
161
+ const { legacyConfig } = await (0, prompts.default)({
162
+ type: "select",
163
+ name: "legacyConfig",
164
+ message: "Which legacy base?",
165
+ choices: [{
166
+ title: "Base",
167
+ description: ansis.default.green("@elinzy/eslint-config-extended base"),
168
+ value: require_common.legacyConfigs.BASE
169
+ }, {
170
+ title: "React",
171
+ description: ansis.default.cyan("@elinzy/eslint-config-extended react"),
172
+ value: require_common.legacyConfigs.REACT
173
+ }],
174
+ onState: require_functions.onPromptState
175
+ }, { onCancel: require_functions.onCancel });
176
+ args = {
177
+ ...args,
178
+ legacyConfig
179
+ };
180
+ if (args.legacyConfig === require_common.legacyConfigs.REACT) {
181
+ const { reactHooks } = await (0, prompts.default)({
182
+ type: "toggle",
183
+ name: "reactHooks",
184
+ message: "Using React Hooks?",
185
+ initial: require_common.defaults.legacyReactHooks,
186
+ active: "Yes",
187
+ inactive: "No",
188
+ onState: require_functions.onPromptState
189
+ }, { onCancel: require_functions.onCancel });
190
+ args = {
191
+ ...args,
192
+ legacyConfig: reactHooks ? require_common.legacyConfigs.REACT_HOOKS : require_common.legacyConfigs.REACT
193
+ };
194
+ }
195
+ }
196
+ if (args.createEslintFile === null) {
197
+ const { createEslintFile } = await (0, prompts.default)({
198
+ type: "toggle",
199
+ name: "createEslintFile",
200
+ message: `Create ${ansis.default.blue(require_common.eslintConfigName)} file?`,
201
+ initial: require_common.defaults.createEslintFile,
202
+ active: "Yes",
203
+ inactive: "No",
204
+ onState: require_functions.onPromptState
205
+ }, { onCancel: require_functions.onCancel });
206
+ args = {
207
+ ...args,
208
+ createEslintFile
209
+ };
210
+ }
211
+ if (args.skipInstall === null) {
212
+ const { skipInstall } = await (0, prompts.default)({
213
+ type: "toggle",
214
+ name: "skipInstall",
215
+ message: "Skip package installation?",
216
+ initial: require_common.defaults.skipInstall,
217
+ active: "Yes",
218
+ inactive: "No",
219
+ onState: require_functions.onPromptState
220
+ }, { onCancel: require_functions.onCancel });
221
+ args = {
222
+ ...args,
223
+ skipInstall
224
+ };
225
+ }
226
+ const configUrl = require_index$3.getConfigUrl({
227
+ config: args.config,
228
+ language: args.language,
229
+ formatter: args.formatter,
230
+ runtime: args.runtime,
231
+ strictConfig: args.strictConfig,
232
+ legacyConfig: args.legacyConfig
233
+ });
234
+ console.log();
235
+ console.log(ansis.default.cyan("Template:"), configUrl.path);
236
+ if (args.createEslintFile && configUrl) {
237
+ const outputPath = node_path.default.resolve(process.cwd(), require_common.eslintConfigName);
238
+ await require_index$1.createESLintConfigFile({
239
+ configPath: configUrl.path,
240
+ outputPath
241
+ });
242
+ }
243
+ if (args.skipInstall) {
244
+ const commands = require_index$2.getCommands({ formatter: args.formatter });
245
+ console.log();
246
+ console.log(ansis.default.yellow("Install manually:"));
247
+ console.log(ansis.default.blue(commands.join(" ")));
248
+ } else {
249
+ console.log();
250
+ console.log(ansis.default.blue("Installing packages..."));
251
+ await require_index$4.installPackages({ formatter: args.formatter });
252
+ console.log(ansis.default.green("Installation complete!"));
253
+ }
254
+ console.log();
255
+ };
256
+ //#endregion
257
+ exports.default = eslint;
258
+ exports.eslint = eslint;
@@ -0,0 +1,253 @@
1
+ #!/usr/bin/env node
2
+ import { handleSigTerm, onCancel, onPromptState } from "../utils/functions.mjs";
3
+ import { configs, defaults, eslintConfigName, formatters, languages, legacyConfigs, runtimes, strictConfigs } from "../constants/common.mjs";
4
+ import "../constants/index.mjs";
5
+ import { createESLintConfigFile } from "../helpers/createEslintConfigFile/index.mjs";
6
+ import { getCommands } from "../helpers/getCommands/index.mjs";
7
+ import { getConfigUrl } from "../helpers/getConfigUrl/index.mjs";
8
+ import { installPackages } from "../helpers/installPackages/index.mjs";
9
+ import pc from "ansis";
10
+ import path from "node:path";
11
+ import prompts from "prompts";
12
+ //#region src/commands/eslint.ts
13
+ const eslint = async () => {
14
+ process.on("SIGINT", handleSigTerm);
15
+ process.on("SIGTERM", handleSigTerm);
16
+ let args = {
17
+ config: null,
18
+ language: null,
19
+ formatter: null,
20
+ runtime: null,
21
+ strictConfig: null,
22
+ legacyConfig: null,
23
+ createEslintFile: null,
24
+ skipInstall: null
25
+ };
26
+ if (args.config === null) {
27
+ const { configBoolean } = await prompts({
28
+ type: "toggle",
29
+ name: "configBoolean",
30
+ message: "Config type?",
31
+ initial: defaults.config === configs.EXTENDED,
32
+ active: "Extended (flat config)",
33
+ inactive: "Legacy (.eslintrc)",
34
+ onState: onPromptState
35
+ }, { onCancel });
36
+ const config = configBoolean ? configs.EXTENDED : configs.LEGACY;
37
+ args = {
38
+ ...args,
39
+ config,
40
+ ...config === configs.EXTENDED ? { legacyConfig: null } : { runtime: null }
41
+ };
42
+ }
43
+ if (args.language === null) {
44
+ const { languageBoolean } = await prompts({
45
+ type: "toggle",
46
+ name: "languageBoolean",
47
+ message: `Are you using ${pc.blue("TypeScript")}?`,
48
+ initial: defaults.language === languages.TYPESCRIPT,
49
+ active: "Yes",
50
+ inactive: "No",
51
+ onState: onPromptState
52
+ }, { onCancel });
53
+ args = {
54
+ ...args,
55
+ language: languageBoolean ? languages.TYPESCRIPT : languages.JAVASCRIPT
56
+ };
57
+ }
58
+ if (args.formatter === formatters.NONE) args = {
59
+ ...args,
60
+ formatter: null
61
+ };
62
+ else if (args.formatter === null) {
63
+ const { formatterBoolean } = await prompts({
64
+ type: "toggle",
65
+ name: "formatterBoolean",
66
+ message: `Are you using ${pc.cyan("Prettier")}?`,
67
+ initial: defaults.formatter === formatters.PRETTIER,
68
+ active: "Yes",
69
+ inactive: "No",
70
+ onState: onPromptState
71
+ }, { onCancel });
72
+ args = {
73
+ ...args,
74
+ formatter: formatterBoolean ? formatters.PRETTIER : null
75
+ };
76
+ }
77
+ if (args.config === configs.EXTENDED && !args.runtime) {
78
+ const { runtime } = await prompts({
79
+ type: "select",
80
+ name: "runtime",
81
+ message: "Which runtime?",
82
+ choices: [
83
+ {
84
+ title: "Node.js",
85
+ description: pc.green("Node.js backend or library"),
86
+ value: runtimes.NODE
87
+ },
88
+ {
89
+ title: "React",
90
+ description: pc.cyan("React.js with JSX"),
91
+ value: runtimes.REACT
92
+ },
93
+ {
94
+ title: "Next.js",
95
+ description: pc.blackBright("Next.js framework"),
96
+ value: runtimes.NEXT
97
+ }
98
+ ],
99
+ onState: onPromptState
100
+ }, { onCancel });
101
+ args = {
102
+ ...args,
103
+ runtime
104
+ };
105
+ }
106
+ if (args.config === configs.EXTENDED) {
107
+ if (args.strictConfig?.includes(strictConfigs.NONE)) args = {
108
+ ...args,
109
+ strictConfig: null
110
+ };
111
+ else if (!args.strictConfig) {
112
+ const { hasStrictConfig } = await prompts({
113
+ type: "toggle",
114
+ name: "hasStrictConfig",
115
+ message: `Add ${pc.yellow("strict")} configs?`,
116
+ initial: defaults.strictConfig,
117
+ active: "Yes",
118
+ inactive: "No",
119
+ onState: onPromptState
120
+ }, { onCancel });
121
+ if (hasStrictConfig) {
122
+ const { strictConfig } = await prompts({
123
+ type: "multiselect",
124
+ name: "strictConfig",
125
+ message: "Select strict configs:",
126
+ min: 1,
127
+ choices: [
128
+ {
129
+ title: "Import",
130
+ description: pc.yellow("Strict import rules"),
131
+ value: strictConfigs.IMPORT
132
+ },
133
+ ...args.runtime && [runtimes.REACT, runtimes.NEXT].includes(args.runtime) ? [{
134
+ title: "React",
135
+ description: pc.cyan("Strict React rules"),
136
+ value: strictConfigs.REACT
137
+ }] : [],
138
+ ...args.language === languages.TYPESCRIPT ? [{
139
+ title: "TypeScript",
140
+ description: pc.blue("Strict TypeScript rules"),
141
+ value: strictConfigs.TYPESCRIPT
142
+ }] : []
143
+ ],
144
+ onState: onPromptState
145
+ }, { onCancel });
146
+ args = {
147
+ ...args,
148
+ strictConfig
149
+ };
150
+ } else args = {
151
+ ...args,
152
+ strictConfig: null
153
+ };
154
+ }
155
+ }
156
+ if (args.config === configs.LEGACY && !args.legacyConfig) {
157
+ const { legacyConfig } = await prompts({
158
+ type: "select",
159
+ name: "legacyConfig",
160
+ message: "Which legacy base?",
161
+ choices: [{
162
+ title: "Base",
163
+ description: pc.green("@elinzy/eslint-config-extended base"),
164
+ value: legacyConfigs.BASE
165
+ }, {
166
+ title: "React",
167
+ description: pc.cyan("@elinzy/eslint-config-extended react"),
168
+ value: legacyConfigs.REACT
169
+ }],
170
+ onState: onPromptState
171
+ }, { onCancel });
172
+ args = {
173
+ ...args,
174
+ legacyConfig
175
+ };
176
+ if (args.legacyConfig === legacyConfigs.REACT) {
177
+ const { reactHooks } = await prompts({
178
+ type: "toggle",
179
+ name: "reactHooks",
180
+ message: "Using React Hooks?",
181
+ initial: defaults.legacyReactHooks,
182
+ active: "Yes",
183
+ inactive: "No",
184
+ onState: onPromptState
185
+ }, { onCancel });
186
+ args = {
187
+ ...args,
188
+ legacyConfig: reactHooks ? legacyConfigs.REACT_HOOKS : legacyConfigs.REACT
189
+ };
190
+ }
191
+ }
192
+ if (args.createEslintFile === null) {
193
+ const { createEslintFile } = await prompts({
194
+ type: "toggle",
195
+ name: "createEslintFile",
196
+ message: `Create ${pc.blue(eslintConfigName)} file?`,
197
+ initial: defaults.createEslintFile,
198
+ active: "Yes",
199
+ inactive: "No",
200
+ onState: onPromptState
201
+ }, { onCancel });
202
+ args = {
203
+ ...args,
204
+ createEslintFile
205
+ };
206
+ }
207
+ if (args.skipInstall === null) {
208
+ const { skipInstall } = await prompts({
209
+ type: "toggle",
210
+ name: "skipInstall",
211
+ message: "Skip package installation?",
212
+ initial: defaults.skipInstall,
213
+ active: "Yes",
214
+ inactive: "No",
215
+ onState: onPromptState
216
+ }, { onCancel });
217
+ args = {
218
+ ...args,
219
+ skipInstall
220
+ };
221
+ }
222
+ const configUrl = getConfigUrl({
223
+ config: args.config,
224
+ language: args.language,
225
+ formatter: args.formatter,
226
+ runtime: args.runtime,
227
+ strictConfig: args.strictConfig,
228
+ legacyConfig: args.legacyConfig
229
+ });
230
+ console.log();
231
+ console.log(pc.cyan("Template:"), configUrl.path);
232
+ if (args.createEslintFile && configUrl) {
233
+ const outputPath = path.resolve(process.cwd(), eslintConfigName);
234
+ await createESLintConfigFile({
235
+ configPath: configUrl.path,
236
+ outputPath
237
+ });
238
+ }
239
+ if (args.skipInstall) {
240
+ const commands = getCommands({ formatter: args.formatter });
241
+ console.log();
242
+ console.log(pc.yellow("Install manually:"));
243
+ console.log(pc.blue(commands.join(" ")));
244
+ } else {
245
+ console.log();
246
+ console.log(pc.blue("Installing packages..."));
247
+ await installPackages({ formatter: args.formatter });
248
+ console.log(pc.green("Installation complete!"));
249
+ }
250
+ console.log();
251
+ };
252
+ //#endregion
253
+ export { eslint as default, eslint };
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ //#region src/constants/common.ts
3
+ const configs = {
4
+ EXTENDED: "extended",
5
+ LEGACY: "legacy"
6
+ };
7
+ const languages = {
8
+ JAVASCRIPT: "javascript",
9
+ TYPESCRIPT: "typescript"
10
+ };
11
+ const formatters = {
12
+ NONE: "none",
13
+ PRETTIER: "prettier"
14
+ };
15
+ const runtimes = {
16
+ REACT: "react",
17
+ NEXT: "next",
18
+ NODE: "node"
19
+ };
20
+ const strictConfigs = {
21
+ NONE: "none",
22
+ IMPORT: "import",
23
+ REACT: "react",
24
+ TYPESCRIPT: "typescript"
25
+ };
26
+ const legacyConfigs = {
27
+ BASE: "base",
28
+ REACT: "react",
29
+ REACT_HOOKS: "react-hooks"
30
+ };
31
+ const defaults = {
32
+ config: configs.EXTENDED,
33
+ language: languages.TYPESCRIPT,
34
+ formatter: formatters.PRETTIER,
35
+ strictConfig: false,
36
+ legacyReactHooks: true,
37
+ createEslintFile: true,
38
+ skipInstall: false
39
+ };
40
+ const subFolders = {
41
+ DEFAULT: "default",
42
+ STRICT: "strict"
43
+ };
44
+ const eslintConfigName = "eslint.config.mjs";
45
+ //#endregion
46
+ exports.configs = configs;
47
+ exports.defaults = defaults;
48
+ exports.eslintConfigName = eslintConfigName;
49
+ exports.formatters = formatters;
50
+ exports.languages = languages;
51
+ exports.legacyConfigs = legacyConfigs;
52
+ exports.runtimes = runtimes;
53
+ exports.strictConfigs = strictConfigs;
54
+ exports.subFolders = subFolders;
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ //#region src/constants/common.ts
3
+ const configs = {
4
+ EXTENDED: "extended",
5
+ LEGACY: "legacy"
6
+ };
7
+ const languages = {
8
+ JAVASCRIPT: "javascript",
9
+ TYPESCRIPT: "typescript"
10
+ };
11
+ const formatters = {
12
+ NONE: "none",
13
+ PRETTIER: "prettier"
14
+ };
15
+ const runtimes = {
16
+ REACT: "react",
17
+ NEXT: "next",
18
+ NODE: "node"
19
+ };
20
+ const strictConfigs = {
21
+ NONE: "none",
22
+ IMPORT: "import",
23
+ REACT: "react",
24
+ TYPESCRIPT: "typescript"
25
+ };
26
+ const legacyConfigs = {
27
+ BASE: "base",
28
+ REACT: "react",
29
+ REACT_HOOKS: "react-hooks"
30
+ };
31
+ const defaults = {
32
+ config: configs.EXTENDED,
33
+ language: languages.TYPESCRIPT,
34
+ formatter: formatters.PRETTIER,
35
+ strictConfig: false,
36
+ legacyReactHooks: true,
37
+ createEslintFile: true,
38
+ skipInstall: false
39
+ };
40
+ const subFolders = {
41
+ DEFAULT: "default",
42
+ STRICT: "strict"
43
+ };
44
+ const eslintConfigName = "eslint.config.mjs";
45
+ //#endregion
46
+ export { configs, defaults, eslintConfigName, formatters, languages, legacyConfigs, runtimes, strictConfigs, subFolders };
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ const require_common = require("./common.cjs");
3
+ exports.configs = require_common.configs;
4
+ exports.defaults = require_common.defaults;
5
+ exports.eslintConfigName = require_common.eslintConfigName;
6
+ exports.formatters = require_common.formatters;
7
+ exports.languages = require_common.languages;
8
+ exports.legacyConfigs = require_common.legacyConfigs;
9
+ exports.runtimes = require_common.runtimes;
10
+ exports.strictConfigs = require_common.strictConfigs;
11
+ exports.subFolders = require_common.subFolders;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export { configs, defaults, eslintConfigName, formatters, languages, legacyConfigs, runtimes, strictConfigs, subFolders } from "./common.mjs";
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
3
+ let node_path = require("node:path");
4
+ node_path = require_runtime.__toESM(node_path, 1);
5
+ let node_fs = require("node:fs");
6
+ node_fs = require_runtime.__toESM(node_fs, 1);
7
+ //#region src/helpers/createEslintConfigFile/index.ts
8
+ /**
9
+ * Resolve templates directory from the `@elinzy/build-templates` package.
10
+ * Uses import.meta.resolve to find the package, then reads templates locally.
11
+ */
12
+ const templatesDir = (() => {
13
+ const resolvePaths = [
14
+ node_path.default.resolve(__dirname, "..", "..", "..", "build-templates", "templates"),
15
+ node_path.default.resolve(__dirname, "..", "..", "..", "..", "build-templates", "templates"),
16
+ node_path.default.resolve(process.cwd(), "packages", "build-templates", "templates")
17
+ ];
18
+ for (const p of resolvePaths) if (node_fs.default.existsSync(p)) return p;
19
+ return null;
20
+ })();
21
+ const createESLintConfigFile = async (config) => {
22
+ const { configPath, outputPath } = config;
23
+ if (!templatesDir) throw new Error("Cannot find @elinzy/build-templates package. Please ensure it is installed.");
24
+ const templateFile = node_path.default.join(templatesDir, configPath);
25
+ if (!node_fs.default.existsSync(templateFile)) {
26
+ console.warn(`Template not found: ${configPath}`);
27
+ console.warn(`Searched: ${templateFile}`);
28
+ return;
29
+ }
30
+ const content = node_fs.default.readFileSync(templateFile, "utf8");
31
+ node_fs.default.writeFileSync(outputPath, content, "utf8");
32
+ console.log(`Created: ${outputPath}`);
33
+ console.log(`Template: ${baseGithubUrl}/${configPath}`);
34
+ };
35
+ const baseGithubUrl = "https://github.com/Appleec/e/tree/main/packages/build-templates/templates";
36
+ //#endregion
37
+ exports.baseGithubUrl = baseGithubUrl;
38
+ exports.createESLintConfigFile = createESLintConfigFile;
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path";
3
+ import fs from "node:fs";
4
+ //#region src/helpers/createEslintConfigFile/index.ts
5
+ /**
6
+ * Resolve templates directory from the `@elinzy/build-templates` package.
7
+ * Uses import.meta.resolve to find the package, then reads templates locally.
8
+ */
9
+ const templatesDir = (() => {
10
+ const resolvePaths = [
11
+ path.resolve(import.meta.dirname, "..", "..", "..", "build-templates", "templates"),
12
+ path.resolve(import.meta.dirname, "..", "..", "..", "..", "build-templates", "templates"),
13
+ path.resolve(process.cwd(), "packages", "build-templates", "templates")
14
+ ];
15
+ for (const p of resolvePaths) if (fs.existsSync(p)) return p;
16
+ return null;
17
+ })();
18
+ const createESLintConfigFile = async (config) => {
19
+ const { configPath, outputPath } = config;
20
+ if (!templatesDir) throw new Error("Cannot find @elinzy/build-templates package. Please ensure it is installed.");
21
+ const templateFile = path.join(templatesDir, configPath);
22
+ if (!fs.existsSync(templateFile)) {
23
+ console.warn(`Template not found: ${configPath}`);
24
+ console.warn(`Searched: ${templateFile}`);
25
+ return;
26
+ }
27
+ const content = fs.readFileSync(templateFile, "utf8");
28
+ fs.writeFileSync(outputPath, content, "utf8");
29
+ console.log(`Created: ${outputPath}`);
30
+ console.log(`Template: ${baseGithubUrl}/${configPath}`);
31
+ };
32
+ const baseGithubUrl = "https://github.com/Appleec/e/tree/main/packages/build-templates/templates";
33
+ //#endregion
34
+ export { baseGithubUrl, createESLintConfigFile };
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ const require_common = require("../../constants/common.cjs");
3
+ require("../../constants/index.cjs");
4
+ //#region src/helpers/getCommands/index.ts
5
+ const getCommands = (args) => {
6
+ const { formatter } = args;
7
+ const commands = [
8
+ "pnpm",
9
+ "add",
10
+ "-D",
11
+ "eslint",
12
+ "@eslint/compat",
13
+ "@eslint/js",
14
+ "@elinzy/eslint-config-extended"
15
+ ];
16
+ if (formatter === require_common.formatters.PRETTIER) commands.push("prettier", "eslint-plugin-prettier", "eslint-config-prettier");
17
+ return commands;
18
+ };
19
+ //#endregion
20
+ exports.getCommands = getCommands;
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import { formatters } from "../../constants/common.mjs";
3
+ import "../../constants/index.mjs";
4
+ //#region src/helpers/getCommands/index.ts
5
+ const getCommands = (args) => {
6
+ const { formatter } = args;
7
+ const commands = [
8
+ "pnpm",
9
+ "add",
10
+ "-D",
11
+ "eslint",
12
+ "@eslint/compat",
13
+ "@eslint/js",
14
+ "@elinzy/eslint-config-extended"
15
+ ];
16
+ if (formatter === formatters.PRETTIER) commands.push("prettier", "eslint-plugin-prettier", "eslint-config-prettier");
17
+ return commands;
18
+ };
19
+ //#endregion
20
+ export { getCommands };
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ const require_common = require("../../constants/common.cjs");
3
+ require("../../constants/index.cjs");
4
+ //#region src/helpers/getConfigUrl/index.ts
5
+ const getConfigUrl = (args) => {
6
+ const { config, language, formatter, strictConfig, runtime, legacyConfig } = args;
7
+ const isLegacy = config === require_common.configs.LEGACY;
8
+ const prettierText = formatter === require_common.formatters.PRETTIER ? "prettier" : null;
9
+ const tsOrJsText = language === require_common.languages.TYPESCRIPT ? "ts" : "js";
10
+ const legacyLanguage = config === require_common.configs.EXTENDED ? null : legacyConfig;
11
+ const strictOrDefaultText = (() => {
12
+ if (!strictConfig || strictConfig.length === 0) return [require_common.subFolders.DEFAULT];
13
+ const strictFolder = [...strictConfig].sort().join("-");
14
+ return [require_common.subFolders.STRICT, strictFolder];
15
+ })();
16
+ return { path: [
17
+ ...isLegacy ? [require_common.configs.LEGACY, legacyLanguage] : [runtime],
18
+ prettierText,
19
+ tsOrJsText,
20
+ ...strictOrDefaultText,
21
+ require_common.eslintConfigName
22
+ ].filter(Boolean).join("/") };
23
+ };
24
+ //#endregion
25
+ exports.getConfigUrl = getConfigUrl;
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import { configs, eslintConfigName, formatters, languages, subFolders } from "../../constants/common.mjs";
3
+ import "../../constants/index.mjs";
4
+ //#region src/helpers/getConfigUrl/index.ts
5
+ const getConfigUrl = (args) => {
6
+ const { config, language, formatter, strictConfig, runtime, legacyConfig } = args;
7
+ const isLegacy = config === configs.LEGACY;
8
+ const prettierText = formatter === formatters.PRETTIER ? "prettier" : null;
9
+ const tsOrJsText = language === languages.TYPESCRIPT ? "ts" : "js";
10
+ const legacyLanguage = config === configs.EXTENDED ? null : legacyConfig;
11
+ const strictOrDefaultText = (() => {
12
+ if (!strictConfig || strictConfig.length === 0) return [subFolders.DEFAULT];
13
+ const strictFolder = [...strictConfig].sort().join("-");
14
+ return [subFolders.STRICT, strictFolder];
15
+ })();
16
+ return { path: [
17
+ ...isLegacy ? [configs.LEGACY, legacyLanguage] : [runtime],
18
+ prettierText,
19
+ tsOrJsText,
20
+ ...strictOrDefaultText,
21
+ eslintConfigName
22
+ ].filter(Boolean).join("/") };
23
+ };
24
+ //#endregion
25
+ export { getConfigUrl };
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
3
+ const require_index = require("../getCommands/index.cjs");
4
+ let cross_spawn = require("cross-spawn");
5
+ cross_spawn = require_runtime.__toESM(cross_spawn, 1);
6
+ //#region src/helpers/installPackages/index.ts
7
+ const installPackages = async (args) => {
8
+ const [packageManager, ...commands] = require_index.getCommands(args);
9
+ return new Promise((resolve, reject) => {
10
+ (0, cross_spawn.default)(packageManager, commands, {
11
+ stdio: "inherit",
12
+ env: {
13
+ ...process.env,
14
+ ADBLOCK: "1",
15
+ NODE_ENV: "development",
16
+ DISABLE_OPENCOLLECTIVE: "1"
17
+ }
18
+ }).on("close", (code) => {
19
+ if (code !== 0) {
20
+ reject(new Error(`${packageManager} ${commands.join(" ")}`, { cause: "package-failed" }));
21
+ return;
22
+ }
23
+ resolve();
24
+ });
25
+ });
26
+ };
27
+ //#endregion
28
+ exports.installPackages = installPackages;
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ import { getCommands } from "../getCommands/index.mjs";
3
+ import spawn from "cross-spawn";
4
+ //#region src/helpers/installPackages/index.ts
5
+ const installPackages = async (args) => {
6
+ const [packageManager, ...commands] = getCommands(args);
7
+ return new Promise((resolve, reject) => {
8
+ spawn(packageManager, commands, {
9
+ stdio: "inherit",
10
+ env: {
11
+ ...process.env,
12
+ ADBLOCK: "1",
13
+ NODE_ENV: "development",
14
+ DISABLE_OPENCOLLECTIVE: "1"
15
+ }
16
+ }).on("close", (code) => {
17
+ if (code !== 0) {
18
+ reject(new Error(`${packageManager} ${commands.join(" ")}`, { cause: "package-failed" }));
19
+ return;
20
+ }
21
+ resolve();
22
+ });
23
+ });
24
+ };
25
+ //#endregion
26
+ export { installPackages };
package/dist/index.cjs ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ #!/usr/bin/env node
3
+ const require_functions = require("./utils/functions.cjs");
4
+ const require_package = require("./package.cjs");
5
+ const require_eslint = require("./commands/eslint.cjs");
6
+ //#region src/index.ts
7
+ const program = new (require("commander")).Command().name(require_package.name).version(require_package.version, "-v, --version", "Output the current version.").helpOption("-h, --help", "Display help message.");
8
+ program.command("eslint").description("Interactive ESLint config scaffold").action(async () => {
9
+ try {
10
+ await require_eslint.default();
11
+ } catch (error) {
12
+ if (error instanceof Error) require_functions.exit(error);
13
+ else console.error(error);
14
+ }
15
+ });
16
+ program.parse();
17
+ //#endregion
@@ -0,0 +1,2 @@
1
+
2
+ export {}
@@ -0,0 +1,2 @@
1
+
2
+ export {}
package/dist/index.mjs ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ #!/usr/bin/env node
3
+ import { exit } from "./utils/functions.mjs";
4
+ import { name, version } from "./package.mjs";
5
+ import eslint from "./commands/eslint.mjs";
6
+ import { Command } from "commander";
7
+ //#region src/index.ts
8
+ const program = new Command().name(name).version(version, "-v, --version", "Output the current version.").helpOption("-h, --help", "Display help message.");
9
+ program.command("eslint").description("Interactive ESLint config scaffold").action(async () => {
10
+ try {
11
+ await eslint();
12
+ } catch (error) {
13
+ if (error instanceof Error) exit(error);
14
+ else console.error(error);
15
+ }
16
+ });
17
+ program.parse();
18
+ //#endregion
19
+ export {};
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ //#region package.json
3
+ var name = "@elinzy/cli";
4
+ var version = "0.1.4";
5
+ //#endregion
6
+ Object.defineProperty(exports, "name", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return name;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "version", {
13
+ enumerable: true,
14
+ get: function() {
15
+ return version;
16
+ }
17
+ });
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ //#region package.json
3
+ var name = "@elinzy/cli";
4
+ var version = "0.1.4";
5
+ //#endregion
6
+ export { name, version };
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
+ let ansis = require("ansis");
4
+ ansis = require_runtime.__toESM(ansis, 1);
5
+ //#region src/utils/functions.ts
6
+ const handleSigTerm = () => process.exit(0);
7
+ const onPromptState = (state) => {
8
+ if (state.aborted) {
9
+ process.stdout.write("\x1B[?25h");
10
+ process.stdout.write("\n");
11
+ process.exit(1);
12
+ }
13
+ };
14
+ const onCancel = () => {
15
+ console.error("Exiting, bye bye.");
16
+ process.exit(1);
17
+ };
18
+ /**
19
+ * Run Function Catch Block
20
+ * @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/index.ts#L499
21
+ */
22
+ const exit = (error) => {
23
+ console.log("Aborting installation.");
24
+ if (error.cause === "package-failed") console.log(`${ansis.default.red(error.message)} has failed.`);
25
+ else console.log(`${ansis.default.red("Unexpected error. Please report it as a bug:")}\n`, error);
26
+ process.exit(1);
27
+ };
28
+ //#endregion
29
+ exports.exit = exit;
30
+ exports.handleSigTerm = handleSigTerm;
31
+ exports.onCancel = onCancel;
32
+ exports.onPromptState = onPromptState;
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ import pc from "ansis";
3
+ //#region src/utils/functions.ts
4
+ const handleSigTerm = () => process.exit(0);
5
+ const onPromptState = (state) => {
6
+ if (state.aborted) {
7
+ process.stdout.write("\x1B[?25h");
8
+ process.stdout.write("\n");
9
+ process.exit(1);
10
+ }
11
+ };
12
+ const onCancel = () => {
13
+ console.error("Exiting, bye bye.");
14
+ process.exit(1);
15
+ };
16
+ /**
17
+ * Run Function Catch Block
18
+ * @see https://github.com/vercel/next.js/blob/canary/packages/create-next-app/index.ts#L499
19
+ */
20
+ const exit = (error) => {
21
+ console.log("Aborting installation.");
22
+ if (error.cause === "package-failed") console.log(`${pc.red(error.message)} has failed.`);
23
+ else console.log(`${pc.red("Unexpected error. Please report it as a bug:")}\n`, error);
24
+ process.exit(1);
25
+ };
26
+ //#endregion
27
+ export { exit, handleSigTerm, onCancel, onPromptState };
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@elinzy/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.4",
4
+ "description": "A collection of common scripts and commands for e",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "types": "./dist/index.d.mts",
8
+ "exports": {
9
+ ".": {
10
+ "types": {
11
+ "import": "./dist/index.d.mts",
12
+ "require": "./dist/index.d.cts"
13
+ },
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.cjs"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "registry": "https://registry.npmjs.org/"
25
+ },
26
+ "bin": {
27
+ "e": "./dist/index.mjs",
28
+ "e-cli": "./dist/index.mjs"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/Appleec/e.git",
33
+ "directory": "packages/cli"
34
+ },
35
+ "keywords": [
36
+ "e",
37
+ "cli"
38
+ ],
39
+ "author": "Appleec <771992522@qq.com>",
40
+ "license": "MIT",
41
+ "bugs": {
42
+ "url": "https://github.com/Appleec/e/issues"
43
+ },
44
+ "homepage": "https://github.com/Appleec/e#readme",
45
+ "dependencies": {
46
+ "ansis": "^3.17.0",
47
+ "commander": "^14.0.3",
48
+ "conventional-changelog": "^6.0.0",
49
+ "cross-spawn": "^7.0.6",
50
+ "nanospinner": "^1.2.2",
51
+ "node-fetch": "3.3.2",
52
+ "package-manager-detector": "1.6.0",
53
+ "prompts": "^2.4.2",
54
+ "semver": "^7.7.1",
55
+ "@elinzy/core": "^0.1.2",
56
+ "@elinzy/build-templates": "0.1.0",
57
+ "@elinzy/logger": "1.0.0"
58
+ },
59
+ "engines": {
60
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
61
+ },
62
+ "devDependencies": {
63
+ "tsdown": "^0.23.1"
64
+ },
65
+ "scripts": {
66
+ "dev": "tsx src/index.ts",
67
+ "build": "tsdown",
68
+ "typecheck": "tsc --noEmit",
69
+ "test": "echo \"Error: no test specified\" && exit 1"
70
+ }
6
71
  }