@outwalk/create-firefly 0.14.1 → 0.14.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/README.md +3 -4
- package/dist/index.js +29 -19
- package/package.json +12 -10
package/README.md
CHANGED
|
@@ -19,13 +19,15 @@ npm create @outwalk/firefly@latest
|
|
|
19
19
|
You can also specify settings via command line options.
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
npm create @outwalk/firefly@latest my-app --language typescript
|
|
22
|
+
npm create @outwalk/firefly@latest my-app -- --language typescript
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
### Command Line Options.
|
|
26
26
|
|
|
27
27
|
The first argument passed to the command will be used as the project name/directory, Other settings can be configured using the following command line options:
|
|
28
28
|
|
|
29
|
+
NOTE: Command line options are only applied if used after an additional `--` marker.
|
|
30
|
+
|
|
29
31
|
```
|
|
30
32
|
# Specify the language
|
|
31
33
|
-l, --language
|
|
@@ -33,9 +35,6 @@ The first argument passed to the command will be used as the project name/direct
|
|
|
33
35
|
# Specify the platform
|
|
34
36
|
-p, --platform
|
|
35
37
|
|
|
36
|
-
# Specify the database
|
|
37
|
-
-d, --database
|
|
38
|
-
|
|
39
38
|
# Prevent automatic dependency installation
|
|
40
39
|
--skip-install
|
|
41
40
|
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import yargs from 'yargs-parser';
|
|
3
|
+
import prompts from 'prompts';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
import { exec, spawnSync } from 'node:child_process';
|
|
8
|
+
import path$1 from 'path';
|
|
9
|
+
import url from 'url';
|
|
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 } = 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
|
+
exec("git init", { cwd: directory });
|
|
111
111
|
resolve();
|
|
112
112
|
} catch {
|
|
113
113
|
reject(new Error("failed to initialize the git repository."));
|
|
@@ -115,12 +115,23 @@ function intitializeGitRepository(directory) {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
const Module = {
|
|
119
|
+
__filename: (fileUrl) => {
|
|
120
|
+
return import.meta.url ? url.fileURLToPath(fileUrl) : __filename;
|
|
121
|
+
},
|
|
122
|
+
__dirname: (fileUrl) => {
|
|
123
|
+
return import.meta.url ? path$1.dirname(Module.__filename(fileUrl)) : __dirname;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
118
127
|
const args = yargs(process.argv.slice(2));
|
|
119
128
|
prompts.override({
|
|
120
129
|
name: args._[0],
|
|
121
130
|
language: args.l ?? args.language,
|
|
122
131
|
platform: args.p ?? args.platform
|
|
123
132
|
});
|
|
133
|
+
const express = { template: "express", dependencies: ["express"] };
|
|
134
|
+
const hono = { template: "hono", dependencies: ["hono", "@hono/node-server"] };
|
|
124
135
|
const questions = [
|
|
125
136
|
{
|
|
126
137
|
type: "text",
|
|
@@ -142,8 +153,8 @@ const questions = [
|
|
|
142
153
|
name: "platform",
|
|
143
154
|
message: "Select a platform:",
|
|
144
155
|
choices: [
|
|
145
|
-
{ title: "Express", value:
|
|
146
|
-
{ title: "Hono", value:
|
|
156
|
+
{ title: "Express", value: JSON.stringify(express) },
|
|
157
|
+
{ title: "Hono", value: JSON.stringify(hono) }
|
|
147
158
|
]
|
|
148
159
|
}
|
|
149
160
|
];
|
|
@@ -152,12 +163,12 @@ const questions = [
|
|
|
152
163
|
const skipInstall = args["skip-install"];
|
|
153
164
|
const skipGit = args["skip-git"];
|
|
154
165
|
const force = args["force"];
|
|
166
|
+
const platform = JSON.parse(config.platform);
|
|
155
167
|
const settings = { useCurrentDirectory: false };
|
|
156
|
-
const dependencies = ["@outwalk/firefly"];
|
|
168
|
+
const dependencies = ["@outwalk/firefly", ...platform.dependencies];
|
|
157
169
|
if (config.language != "javascript") {
|
|
158
170
|
dependencies.push(config.language);
|
|
159
171
|
}
|
|
160
|
-
dependencies.push(...config.platform.split(","));
|
|
161
172
|
if (config.name == ".") {
|
|
162
173
|
if (!force && fs.readdirSync(config.name).length > 0) {
|
|
163
174
|
const response = await prompts({
|
|
@@ -181,15 +192,14 @@ const questions = [
|
|
|
181
192
|
}
|
|
182
193
|
console.log("\n");
|
|
183
194
|
logger.log(`creating ${config.name}...`);
|
|
184
|
-
const templatePath = path.join(__dirname, "../templates/", config.language);
|
|
185
|
-
const snippetPath = path.join(__dirname, "../templates/snippets");
|
|
195
|
+
const templatePath = path.join(Module.__dirname(import.meta.url), "../templates/", config.language);
|
|
196
|
+
const snippetPath = path.join(Module.__dirname(import.meta.url), "../templates/snippets");
|
|
186
197
|
const projectPath = !settings.useCurrentDirectory ? config.name : ".";
|
|
187
198
|
try {
|
|
188
199
|
const template = new TemplateBuilder(templatePath, projectPath);
|
|
189
200
|
template.inject("project-name", config.name);
|
|
190
|
-
|
|
191
|
-
template.snippet("
|
|
192
|
-
template.snippet("define-platform", path.join(snippetPath, platform, "define-platform.template"));
|
|
201
|
+
template.snippet("import-platform", path.join(snippetPath, platform.template, "import-platform.template"));
|
|
202
|
+
template.snippet("define-platform", path.join(snippetPath, platform.template, "define-platform.template"));
|
|
193
203
|
template.build();
|
|
194
204
|
} catch (error) {
|
|
195
205
|
logger.error(error.message);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outwalk/create-firefly",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.14.3",
|
|
4
5
|
"description": "Firefly - a modern scalable web framework.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -18,11 +18,13 @@
|
|
|
18
18
|
"prepublishOnly": "npm run lint && npm run build"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
|
-
"outwalk",
|
|
22
21
|
"express",
|
|
23
22
|
"hono",
|
|
24
23
|
"decorators",
|
|
25
|
-
"
|
|
24
|
+
"project",
|
|
25
|
+
"generator",
|
|
26
|
+
"framework",
|
|
27
|
+
"templates"
|
|
26
28
|
],
|
|
27
29
|
"files": [
|
|
28
30
|
"dist",
|
|
@@ -45,14 +47,14 @@
|
|
|
45
47
|
"yargs-parser": "^22.0.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"@eslint/js": "^
|
|
49
|
-
"@rollup/plugin-commonjs": "^29.0.
|
|
50
|
+
"@eslint/js": "^10.0.1",
|
|
51
|
+
"@rollup/plugin-commonjs": "^29.0.2",
|
|
50
52
|
"@rollup/plugin-json": "^6.1.0",
|
|
51
53
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
52
|
-
"esbuild": "^0.27.
|
|
53
|
-
"eslint": "^
|
|
54
|
-
"globals": "^
|
|
55
|
-
"rollup": "^4.
|
|
54
|
+
"esbuild": "^0.27.4",
|
|
55
|
+
"eslint": "^10.1.0",
|
|
56
|
+
"globals": "^17.4.0",
|
|
57
|
+
"rollup": "^4.60.0",
|
|
56
58
|
"rollup-plugin-esbuild": "^6.2.1"
|
|
57
59
|
}
|
|
58
60
|
}
|