@expressots/cli 3.0.0-beta.1 → 3.0.0-beta.3
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/commands/project.commands.js +26 -11
- package/bin/new/cli.js +1 -1
- package/bin/new/form.d.ts +3 -2
- package/bin/new/form.js +10 -7
- package/package.json +2 -3
|
@@ -59,13 +59,26 @@ function getOutDir() {
|
|
|
59
59
|
* @param compiler The compiler to load the configuration from
|
|
60
60
|
* @returns The configuration
|
|
61
61
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
async function opinionatedConfig() {
|
|
63
|
+
const { entryPoint } = await compiler_1.default.loadConfig();
|
|
64
|
+
const config = [
|
|
65
|
+
"--watch",
|
|
66
|
+
"-r",
|
|
67
|
+
"tsconfig-paths/register",
|
|
68
|
+
`./src/${entryPoint}.ts`,
|
|
69
|
+
];
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Load the configuration from the compiler
|
|
74
|
+
* @param compiler The compiler to load the configuration from
|
|
75
|
+
* @returns The configuration
|
|
76
|
+
*/
|
|
77
|
+
async function nonOpinionatedConfig() {
|
|
78
|
+
const { entryPoint } = await compiler_1.default.loadConfig();
|
|
79
|
+
const config = ["--watch", `./src/${entryPoint}.ts`];
|
|
80
|
+
return config;
|
|
81
|
+
}
|
|
69
82
|
/**
|
|
70
83
|
* Dev command module
|
|
71
84
|
* @type {CommandModule<object, object>}
|
|
@@ -173,12 +186,14 @@ const clearScreen = () => {
|
|
|
173
186
|
* @param command The command to run
|
|
174
187
|
*/
|
|
175
188
|
const runCommand = async ({ command, }) => {
|
|
176
|
-
const { opinionated } = await compiler_1.default.loadConfig();
|
|
189
|
+
const { opinionated, entryPoint } = await compiler_1.default.loadConfig();
|
|
177
190
|
const outDir = getOutDir();
|
|
178
191
|
try {
|
|
179
192
|
switch (command) {
|
|
180
193
|
case "dev":
|
|
181
|
-
execCmd("tsx", opinionated
|
|
194
|
+
execCmd("tsx", opinionated
|
|
195
|
+
? await opinionatedConfig()
|
|
196
|
+
: await nonOpinionatedConfig());
|
|
182
197
|
break;
|
|
183
198
|
case "build":
|
|
184
199
|
if (!outDir) {
|
|
@@ -199,11 +214,11 @@ const runCommand = async ({ command, }) => {
|
|
|
199
214
|
config = [
|
|
200
215
|
"-r",
|
|
201
216
|
`./${outDir}/register-path.js`,
|
|
202
|
-
`./${outDir}/src
|
|
217
|
+
`./${outDir}/src/${entryPoint}.js`,
|
|
203
218
|
];
|
|
204
219
|
}
|
|
205
220
|
else {
|
|
206
|
-
config = [`./${outDir}
|
|
221
|
+
config = [`./${outDir}/${entryPoint}.js`];
|
|
207
222
|
}
|
|
208
223
|
clearScreen();
|
|
209
224
|
execCmd("node", config);
|
package/bin/new/cli.js
CHANGED
|
@@ -23,7 +23,7 @@ const commandOptions = (yargs) => {
|
|
|
23
23
|
.option("template", {
|
|
24
24
|
describe: "The project template to use",
|
|
25
25
|
type: "string",
|
|
26
|
-
choices: ["opinionated", "non-opinionated"],
|
|
26
|
+
choices: ["opinionated", "non-opinionated", "micro"],
|
|
27
27
|
alias: "t",
|
|
28
28
|
})
|
|
29
29
|
.option("package-manager", {
|
package/bin/new/form.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare enum Template {
|
|
2
|
-
|
|
3
|
-
opinionated = "Opinionated :: Automatically scaffolds resources into a preset project structure. (Recommended)"
|
|
2
|
+
nonopinionated = "Non-Opinionated :: Start with a clean slate and build your project from scratch.",
|
|
3
|
+
opinionated = "Opinionated :: Automatically scaffolds resources into a preset project structure. (Recommended)",
|
|
4
|
+
micro = "Micro :: A minimalistic template for building micro api's."
|
|
4
5
|
}
|
|
5
6
|
declare const enum PackageManager {
|
|
6
7
|
npm = "npm",
|
package/bin/new/form.js
CHANGED
|
@@ -5,19 +5,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.projectForm = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const node_child_process_1 = require("node:child_process");
|
|
9
8
|
const cli_progress_1 = require("cli-progress");
|
|
10
9
|
const degit_1 = __importDefault(require("degit"));
|
|
11
10
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
11
|
+
const node_child_process_1 = require("node:child_process");
|
|
12
12
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
13
13
|
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
const cli_1 = require("../cli");
|
|
14
15
|
const center_text_1 = require("../utils/center-text");
|
|
15
|
-
const cli_ui_1 = require("../utils/cli-ui");
|
|
16
16
|
const change_package_info_1 = require("../utils/change-package-info");
|
|
17
|
-
const
|
|
17
|
+
const cli_ui_1 = require("../utils/cli-ui");
|
|
18
18
|
async function packageManagerInstall({ packageManager, directory, progressBar, }) {
|
|
19
19
|
const command = process.platform === "win32" ? `${packageManager}.cmd` : packageManager;
|
|
20
|
-
const args = ["install", "--
|
|
20
|
+
const args = ["install", "--silent"];
|
|
21
21
|
if (packageManager === "yarn") {
|
|
22
22
|
args.push("--ignore-engines");
|
|
23
23
|
args.splice(args.indexOf("--prefer-offline"), 1);
|
|
@@ -100,8 +100,9 @@ function renameEnvFile(directory) {
|
|
|
100
100
|
}
|
|
101
101
|
var Template;
|
|
102
102
|
(function (Template) {
|
|
103
|
-
Template["
|
|
103
|
+
Template["nonopinionated"] = "Non-Opinionated :: Start with a clean slate and build your project from scratch.";
|
|
104
104
|
Template["opinionated"] = "Opinionated :: Automatically scaffolds resources into a preset project structure. (Recommended)";
|
|
105
|
+
Template["micro"] = "Micro :: A minimalistic template for building micro api's.";
|
|
105
106
|
})(Template || (Template = {}));
|
|
106
107
|
const projectForm = async (projectName, args) => {
|
|
107
108
|
let answer;
|
|
@@ -137,7 +138,8 @@ const projectForm = async (projectName, args) => {
|
|
|
137
138
|
message: "Select a template",
|
|
138
139
|
choices: [
|
|
139
140
|
`Opinionated :: Automatically scaffolds resources into a preset project structure. (${chalk_1.default.yellow("Recommended")})`,
|
|
140
|
-
"
|
|
141
|
+
"NonOpinionated :: Allows users to choose where to scaffold resources, offering flexible project organization.",
|
|
142
|
+
"Micro :: A minimalistic template for building micro api's.",
|
|
141
143
|
],
|
|
142
144
|
},
|
|
143
145
|
{
|
|
@@ -159,8 +161,9 @@ const projectForm = async (projectName, args) => {
|
|
|
159
161
|
}
|
|
160
162
|
// Hashmap of templates and their directories
|
|
161
163
|
const templates = {
|
|
162
|
-
|
|
164
|
+
NonOpinionated: "non_opinionated",
|
|
163
165
|
Opinionated: "opinionated",
|
|
166
|
+
Micro: "micro",
|
|
164
167
|
};
|
|
165
168
|
if (answer.confirm) {
|
|
166
169
|
// Check if package manager is bun and OS is Windows
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expressots/cli",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.3",
|
|
4
4
|
"description": "Expressots CLI - modern, fast, lightweight nodejs web framework (@cli)",
|
|
5
5
|
"author": "Richard Zampieri",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"cp:templates": "node scripts/cp.js ./src/generate/templates ./bin/generate/",
|
|
41
41
|
"clean": "node scripts/rm.js bin",
|
|
42
42
|
"prepublish": "npm run build && npm pack",
|
|
43
|
-
"publish": "npm publish --tag latest",
|
|
44
43
|
"format": "prettier --write \"./src/**/*.ts\" --cache",
|
|
45
44
|
"lint": "eslint \"./src/**/*.ts\"",
|
|
46
45
|
"lint:fix": "eslint \"./src/**/*.ts\" --fix",
|
|
@@ -66,7 +65,7 @@
|
|
|
66
65
|
"@codecov/vite-plugin": "^0.0.1-beta.9",
|
|
67
66
|
"@commitlint/cli": "19.2.1",
|
|
68
67
|
"@commitlint/config-conventional": "19.1.0",
|
|
69
|
-
"@expressots/shared": "0.
|
|
68
|
+
"@expressots/shared": "0.3.0",
|
|
70
69
|
"@release-it/conventional-changelog": "7.0.2",
|
|
71
70
|
"@types/chalk-animation": "1.6.1",
|
|
72
71
|
"@types/cli-progress": "3.11.0",
|