scripting-cli 1.0.2 → 1.0.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.
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
7
|
const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
|
|
8
8
|
const AppJsonPlugin_1 = __importDefault(require("./AppJsonPlugin"));
|
|
9
|
-
const baseDir =
|
|
9
|
+
const baseDir = process.cwd();
|
|
10
10
|
const srcDir = path_1.default.resolve(baseDir, 'src');
|
|
11
11
|
const buildDir = path_1.default.resolve(baseDir, 'build');
|
|
12
12
|
const config = {
|
|
@@ -59,7 +59,10 @@ const config = {
|
|
|
59
59
|
},
|
|
60
60
|
resolve: {
|
|
61
61
|
extensions: ['.tsx', '.ts', '.js'],
|
|
62
|
-
modules: [
|
|
62
|
+
modules: [
|
|
63
|
+
'node_modules',
|
|
64
|
+
srcDir,
|
|
65
|
+
],
|
|
63
66
|
alias: {
|
|
64
67
|
'@': srcDir,
|
|
65
68
|
}
|
package/dist/createApp.js
CHANGED
|
@@ -15,11 +15,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.createApp = void 0;
|
|
16
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
17
|
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
+
const node_child_process_1 = require("node:child_process");
|
|
18
19
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
19
20
|
const promises_1 = require("node:fs/promises");
|
|
20
|
-
console.log(
|
|
21
|
+
console.log(process.cwd());
|
|
21
22
|
function getAppDir(appName) {
|
|
22
|
-
return node_path_1.default.join(
|
|
23
|
+
return node_path_1.default.join(process.cwd(), appName);
|
|
23
24
|
}
|
|
24
25
|
function createAppDir(appName) {
|
|
25
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -155,6 +156,10 @@ function createScriptingDeclaration(appName) {
|
|
|
155
156
|
console.log(chalk_1.default.green(` ✔️ Created ${appName}/src/scripting.d.ts`));
|
|
156
157
|
});
|
|
157
158
|
}
|
|
159
|
+
function installDeps(appName) {
|
|
160
|
+
(0, node_child_process_1.execSync)(`cd ${appName} && npm i -D ts-loader typescript file-loader`);
|
|
161
|
+
console.log(chalk_1.default.green(` ✔️ Scripting application ${chalk_1.default.bold(appName)} created!`));
|
|
162
|
+
}
|
|
158
163
|
function createApp(appName) {
|
|
159
164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
165
|
if (!/^[a-zA-Z]+[a-zA-Z0-9-_]+$/.test(appName)) {
|
|
@@ -168,7 +173,7 @@ function createApp(appName) {
|
|
|
168
173
|
yield createReadme(appName);
|
|
169
174
|
yield createEntryFile(appName);
|
|
170
175
|
yield createScriptingDeclaration(appName);
|
|
171
|
-
|
|
176
|
+
installDeps(appName);
|
|
172
177
|
}
|
|
173
178
|
catch (e) {
|
|
174
179
|
console.log(chalk_1.default.red(`✖️ Create Scripting application failed: ${e.message}`));
|
package/dist/startDevServer.js
CHANGED
|
@@ -89,7 +89,7 @@ function startDevServer() {
|
|
|
89
89
|
res.header('Access-Control-Allow-Methods', 'GET, POST, PATCH, OPTIONS, PUT, DELETE');
|
|
90
90
|
next();
|
|
91
91
|
});
|
|
92
|
-
app.use('/', express_1.default.static(node_path_1.default.resolve(
|
|
92
|
+
app.use('/', express_1.default.static(node_path_1.default.resolve(process.cwd(), '../build')));
|
|
93
93
|
//有新的客户端连接时触发
|
|
94
94
|
io.on('connection', function (socket) {
|
|
95
95
|
console.log(chalk_1.default.green('[DevServer] A client connected.'));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scripting-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "This plugin include all the commands for developing scripting-js apps.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -28,13 +28,9 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"chalk": "^4.1.2",
|
|
30
30
|
"express": "^4.18.2",
|
|
31
|
-
"file-loader": "^6.2.0",
|
|
32
31
|
"minimist": "^1.2.8",
|
|
33
32
|
"socket.io": "^4.7.5",
|
|
34
|
-
"
|
|
35
|
-
"typescript": "^5.1.6",
|
|
36
|
-
"webpack": "^5.88.2",
|
|
37
|
-
"webpack-cli": "^5.1.4"
|
|
33
|
+
"webpack": "^5.88.2"
|
|
38
34
|
},
|
|
39
35
|
"devDependencies": {
|
|
40
36
|
"@types/express": "^4.17.21",
|
|
@@ -5,7 +5,7 @@ import webpack from 'webpack'
|
|
|
5
5
|
|
|
6
6
|
import AppJsonPlugin from './AppJsonPlugin'
|
|
7
7
|
|
|
8
|
-
const baseDir =
|
|
8
|
+
const baseDir = process.cwd()
|
|
9
9
|
const srcDir = path.resolve(baseDir, 'src')
|
|
10
10
|
const buildDir = path.resolve(baseDir, 'build')
|
|
11
11
|
|
|
@@ -59,7 +59,10 @@ const config: webpack.Configuration = {
|
|
|
59
59
|
},
|
|
60
60
|
resolve: {
|
|
61
61
|
extensions: ['.tsx', '.ts', '.js'],
|
|
62
|
-
modules: [
|
|
62
|
+
modules: [
|
|
63
|
+
'node_modules',
|
|
64
|
+
srcDir,
|
|
65
|
+
],
|
|
63
66
|
alias: {
|
|
64
67
|
'@': srcDir,
|
|
65
68
|
}
|
package/src/createApp.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import chalk from 'chalk'
|
|
2
2
|
import path from 'node:path'
|
|
3
|
-
import {
|
|
3
|
+
import { execSync } from 'node:child_process'
|
|
4
4
|
import fs from 'node:fs'
|
|
5
5
|
import { mkdir, writeFile, copyFile } from 'node:fs/promises'
|
|
6
6
|
|
|
7
|
-
console.log(
|
|
7
|
+
console.log(process.cwd())
|
|
8
8
|
|
|
9
9
|
function getAppDir(appName: string) {
|
|
10
|
-
return path.join(
|
|
10
|
+
return path.join(process.cwd(), appName)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
async function createAppDir(appName: string) {
|
|
@@ -181,6 +181,14 @@ async function createScriptingDeclaration(appName: string) {
|
|
|
181
181
|
)
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
function installDeps(appName: string) {
|
|
185
|
+
execSync(`cd ${appName} && npm i -D ts-loader typescript file-loader`)
|
|
186
|
+
|
|
187
|
+
console.log(
|
|
188
|
+
chalk.green(` ✔️ Scripting application ${chalk.bold(appName)} created!`)
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
184
192
|
export async function createApp(appName: string) {
|
|
185
193
|
if (!/^[a-zA-Z]+[a-zA-Z0-9-_]+$/.test(appName)) {
|
|
186
194
|
console.log(
|
|
@@ -197,7 +205,8 @@ export async function createApp(appName: string) {
|
|
|
197
205
|
await createEntryFile(appName)
|
|
198
206
|
await createScriptingDeclaration(appName)
|
|
199
207
|
|
|
200
|
-
|
|
208
|
+
installDeps(appName)
|
|
209
|
+
|
|
201
210
|
} catch (e: any) {
|
|
202
211
|
console.log(
|
|
203
212
|
chalk.red(`✖️ Create Scripting application failed: ${e.message}`)
|