@outwalk/create-firefly 0.10.1 → 0.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/dist/index.js +10 -42
- package/package.json +12 -11
- package/templates/javascript/package.json.template +2 -2
- package/templates/javascript/src/index.js.template +1 -4
- package/templates/snippets/hono/define-platform.template +2 -0
- package/templates/snippets/hono/import-platform.template +1 -0
- package/templates/typescript/package.json.template +3 -3
- package/templates/typescript/src/index.ts.template +1 -4
- package/templates/typescript/tsconfig.json.template +4 -1
- package/templates/snippets/custom-database/javascript/define-database.template +0 -13
- package/templates/snippets/custom-database/javascript/import-database.template +0 -1
- package/templates/snippets/custom-database/typescript/define-database.template +0 -14
- package/templates/snippets/custom-database/typescript/import-database.template +0 -1
- package/templates/snippets/custom-platform/javascript/define-platform.template +0 -11
- package/templates/snippets/custom-platform/javascript/import-platform.template +0 -1
- package/templates/snippets/custom-platform/typescript/define-platform.template +0 -11
- package/templates/snippets/custom-platform/typescript/import-platform.template +0 -1
- package/templates/snippets/mongoose/define-database.template +0 -2
- package/templates/snippets/mongoose/import-database.template +0 -1
package/dist/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
var yargs = require('yargs-parser');
|
|
5
5
|
var prompts = require('prompts');
|
|
6
|
-
var path = require('path');
|
|
7
|
-
var fs = require('fs');
|
|
6
|
+
var path = require('node:path');
|
|
7
|
+
var fs = require('node:fs');
|
|
8
8
|
var chalk = require('chalk');
|
|
9
|
-
var
|
|
9
|
+
var node_child_process = require('node:child_process');
|
|
10
10
|
|
|
11
11
|
const firefly = chalk.hex("#ADFF2F");
|
|
12
12
|
const logger = {
|
|
@@ -91,7 +91,7 @@ function installDependencies(dependencies, directory) {
|
|
|
91
91
|
logger.log("installing dependencies...");
|
|
92
92
|
const command = /^win/.test(process.platform) ? "npm.cmd" : "npm";
|
|
93
93
|
const spawnProcess = (command2, args) => {
|
|
94
|
-
const { status, error } =
|
|
94
|
+
const { status, error } = node_child_process.spawnSync(command2, args, { cwd: directory, stdio: "ignore" });
|
|
95
95
|
if (status != 0) throw new Error("failed to install project dependencies.");
|
|
96
96
|
if (error) throw error;
|
|
97
97
|
};
|
|
@@ -107,7 +107,7 @@ function intitializeGitRepository(directory) {
|
|
|
107
107
|
return new Promise((resolve, reject) => {
|
|
108
108
|
logger.log("initializing git repository...");
|
|
109
109
|
try {
|
|
110
|
-
|
|
110
|
+
node_child_process.exec("git init", { cwd: directory });
|
|
111
111
|
resolve();
|
|
112
112
|
} catch {
|
|
113
113
|
reject(new Error("failed to initialize the git repository."));
|
|
@@ -119,8 +119,7 @@ const args = yargs(process.argv.slice(2));
|
|
|
119
119
|
prompts.override({
|
|
120
120
|
name: args._[0],
|
|
121
121
|
language: args.l ?? args.language,
|
|
122
|
-
platform: args.p ?? args.platform
|
|
123
|
-
database: args.d ?? args.database
|
|
122
|
+
platform: args.p ?? args.platform
|
|
124
123
|
});
|
|
125
124
|
const questions = [
|
|
126
125
|
{
|
|
@@ -144,17 +143,7 @@ const questions = [
|
|
|
144
143
|
message: "Select a platform:",
|
|
145
144
|
choices: [
|
|
146
145
|
{ title: "Express", value: "express" },
|
|
147
|
-
{ title: "
|
|
148
|
-
]
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
type: "select",
|
|
152
|
-
name: "database",
|
|
153
|
-
message: "Select a database:",
|
|
154
|
-
choices: [
|
|
155
|
-
{ title: "Mongoose", value: "mongoose" },
|
|
156
|
-
{ title: "Custom", value: "custom-database" },
|
|
157
|
-
{ title: "None", value: "none" }
|
|
146
|
+
{ title: "Hono", value: "hono,@hono/node-server" }
|
|
158
147
|
]
|
|
159
148
|
}
|
|
160
149
|
];
|
|
@@ -168,12 +157,7 @@ const questions = [
|
|
|
168
157
|
if (config.language != "javascript") {
|
|
169
158
|
dependencies.push(config.language);
|
|
170
159
|
}
|
|
171
|
-
|
|
172
|
-
dependencies.push(config.platform);
|
|
173
|
-
}
|
|
174
|
-
if (!["none", "custom-database"].includes(config.database)) {
|
|
175
|
-
dependencies.push(config.database);
|
|
176
|
-
}
|
|
160
|
+
dependencies.push(...config.platform.split(","));
|
|
177
161
|
if (config.name == ".") {
|
|
178
162
|
if (!force && fs.readdirSync(config.name).length > 0) {
|
|
179
163
|
const response = await prompts({
|
|
@@ -203,24 +187,8 @@ const questions = [
|
|
|
203
187
|
try {
|
|
204
188
|
const template = new TemplateBuilder(templatePath, projectPath);
|
|
205
189
|
template.inject("project-name", config.name);
|
|
206
|
-
template.
|
|
207
|
-
|
|
208
|
-
template.snippet("import-platform", path.join(snippetPath, config.platform, config.language, "import-platform.template"));
|
|
209
|
-
template.snippet("define-platform", path.join(snippetPath, config.platform, config.language, "define-platform.template"));
|
|
210
|
-
} else {
|
|
211
|
-
template.snippet("import-platform", path.join(snippetPath, config.platform, "import-platform.template"));
|
|
212
|
-
template.snippet("define-platform", path.join(snippetPath, config.platform, "define-platform.template"));
|
|
213
|
-
}
|
|
214
|
-
if (config.database.startsWith("custom")) {
|
|
215
|
-
template.snippet("import-database", path.join(snippetPath, config.database, config.language, "import-database.template"));
|
|
216
|
-
template.snippet("define-database", path.join(snippetPath, config.database, config.language, "define-database.template"));
|
|
217
|
-
} else if (config.database != "none") {
|
|
218
|
-
template.snippet("import-database", path.join(snippetPath, config.database, "import-database.template"));
|
|
219
|
-
template.snippet("define-database", path.join(snippetPath, config.database, "define-database.template"));
|
|
220
|
-
} else {
|
|
221
|
-
template.inject("import-database", "");
|
|
222
|
-
template.inject("define-database", "");
|
|
223
|
-
}
|
|
190
|
+
template.snippet("import-platform", path.join(snippetPath, config.platform, "import-platform.template"));
|
|
191
|
+
template.snippet("define-platform", path.join(snippetPath, config.platform, "define-platform.template"));
|
|
224
192
|
template.build();
|
|
225
193
|
} catch (error) {
|
|
226
194
|
logger.error(error.message);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outwalk/create-firefly",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Firefly - a modern scalable web framework.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
10
|
+
"node": ">=22"
|
|
11
11
|
},
|
|
12
12
|
"bin": {
|
|
13
13
|
"create-firefly": "dist/index.js"
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"keywords": [
|
|
21
21
|
"outwalk",
|
|
22
22
|
"express",
|
|
23
|
+
"hono",
|
|
23
24
|
"decorators",
|
|
24
25
|
"mvc"
|
|
25
26
|
],
|
|
@@ -41,17 +42,17 @@
|
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"chalk": "^4.1.2",
|
|
43
44
|
"prompts": "^2.4.2",
|
|
44
|
-
"yargs-parser": "^
|
|
45
|
+
"yargs-parser": "^22.0.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@eslint/js": "^9.
|
|
48
|
-
"@rollup/plugin-commonjs": "^
|
|
48
|
+
"@eslint/js": "^9.39.1",
|
|
49
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
49
50
|
"@rollup/plugin-json": "^6.1.0",
|
|
50
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
51
|
-
"esbuild": "^0.
|
|
52
|
-
"eslint": "^9.
|
|
53
|
-
"globals": "^16.
|
|
54
|
-
"rollup": "^4.
|
|
55
|
-
"rollup-plugin-esbuild": "^6.2.
|
|
51
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
52
|
+
"esbuild": "^0.27.0",
|
|
53
|
+
"eslint": "^9.39.1",
|
|
54
|
+
"globals": "^16.5.0",
|
|
55
|
+
"rollup": "^4.53.2",
|
|
56
|
+
"rollup-plugin-esbuild": "^6.2.1"
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { HonoPlatform } from "@outwalk/firefly/hono";
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": true,
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": "^
|
|
8
|
-
"npm": "^
|
|
7
|
+
"node": "^22",
|
|
8
|
+
"npm": "^10"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "
|
|
11
|
+
"build": "firefly build",
|
|
12
12
|
"lint": "firefly lint",
|
|
13
13
|
"start": "firefly start",
|
|
14
14
|
"dev": "firefly start --dev"
|
|
@@ -3,19 +3,22 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
/* features */
|
|
5
5
|
"experimentalDecorators": true,
|
|
6
|
+
"emitDecoratorMetadata": true,
|
|
6
7
|
"useDefineForClassFields": true,
|
|
7
8
|
|
|
8
9
|
/* syntax */
|
|
9
10
|
"target": "ES2020",
|
|
10
11
|
"module": "ESNext",
|
|
11
12
|
"lib": ["ES2020"],
|
|
13
|
+
"jsx": "preserve",
|
|
12
14
|
"skipLibCheck": true,
|
|
13
15
|
|
|
14
16
|
/* bundler mode */
|
|
15
17
|
"moduleResolution": "Bundler",
|
|
16
18
|
"allowImportingTsExtensions": true,
|
|
19
|
+
"rewriteRelativeImportExtensions": true,
|
|
17
20
|
"resolveJsonModule": true,
|
|
18
|
-
"isolatedModules":
|
|
21
|
+
"isolatedModules": false,
|
|
19
22
|
"noEmit": true,
|
|
20
23
|
|
|
21
24
|
/* import path aliases */
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* implement a database using the firefly database interface */
|
|
2
|
-
class CustomDatabase extends Database {
|
|
3
|
-
|
|
4
|
-
async connect() {
|
|
5
|
-
super.displayConnectionMessage();
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
isConnected() {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const database = new CustomDatabase();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { Database } from "@outwalk/firefly";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* implement a database using the firefly database interface */
|
|
2
|
-
class CustomDatabase extends Database {
|
|
3
|
-
|
|
4
|
-
async connect(): Promise<CustomDatabase> {
|
|
5
|
-
super.displayConnectionMessage();
|
|
6
|
-
return this;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
isConnected(): boolean {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const database = new CustomDatabase();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { Database } from "@outwalk/firefly";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { Platform } from "@outwalk/firefly";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* implement a platform using the firefly platform interface */
|
|
2
|
-
class CustomPlatform extends Platform {
|
|
3
|
-
|
|
4
|
-
loadController(route: string, middleware: Function[], routes: Route[]): void {}
|
|
5
|
-
|
|
6
|
-
loadErrorHandler(): void {}
|
|
7
|
-
|
|
8
|
-
listen(port: number): void {}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const platform = new CustomPlatform();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { Platform, Route } from "@outwalk/firefly";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { MongooseDatabase } from "@outwalk/firefly/mongoose";
|