scripting-cli 1.0.4 → 1.0.6

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/build.js CHANGED
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -6,11 +29,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
29
  exports.buildApp = void 0;
7
30
  const chalk_1 = __importDefault(require("chalk"));
8
31
  const webpack_1 = __importDefault(require("webpack"));
9
- const webpack_config_1 = __importDefault(require("./config/webpack.config"));
10
32
  const cross_zip_1 = require("cross-zip");
33
+ const qrcode_terminal_1 = __importDefault(require("qrcode-terminal"));
11
34
  const node_path_1 = __importDefault(require("node:path"));
35
+ const node_http_1 = __importDefault(require("node:http"));
36
+ const express_1 = __importDefault(require("express"));
37
+ const webpack_config_1 = __importDefault(require("./config/webpack.config"));
38
+ const utils = __importStar(require("./utils"));
39
+ const minimist_1 = __importDefault(require("minimist"));
12
40
  function buildApp() {
13
- const compiler = (0, webpack_1.default)(webpack_config_1.default);
41
+ const webpackConfig = (0, webpack_config_1.default)();
42
+ const appName = Object.keys(webpackConfig.entry)[0];
43
+ const appFile = `${appName}.zip`;
44
+ const outputDir = node_path_1.default.resolve(process.cwd(), appName);
45
+ webpackConfig.output.path = outputDir;
46
+ const compiler = (0, webpack_1.default)(webpackConfig);
14
47
  console.log('Start running build...\n'
15
48
  // +
16
49
  // chalk.green(
@@ -31,17 +64,35 @@ function buildApp() {
31
64
  createAppFile();
32
65
  }
33
66
  });
67
+ function createAppFile() {
68
+ console.log(` ~ Creating ${appFile}....`);
69
+ (0, cross_zip_1.zip)(outputDir, node_path_1.default.resolve(outputDir, appFile), (error) => {
70
+ if (error != null) {
71
+ console.log(chalk_1.default.red('Error zipping app files: \n') + error);
72
+ }
73
+ else {
74
+ console.log(chalk_1.default.green(` ✔️ ${appFile} created.`));
75
+ startServer();
76
+ }
77
+ });
78
+ }
79
+ function startServer() {
80
+ const app = (0, express_1.default)();
81
+ const server = node_http_1.default.createServer(app);
82
+ const args = (0, minimist_1.default)(process.argv.slice(2));
83
+ const ipAddress = utils.getIpAddress();
84
+ const port = args['port'] || 8000;
85
+ app.all('*', function (req, res, next) {
86
+ res.header('Access-Control-Allow-Origin', '*');
87
+ res.header('Access-Control-Allow-Headers', '*');
88
+ res.header('Access-Control-Allow-Methods', 'GET, POST, PATCH, OPTIONS, PUT, DELETE');
89
+ next();
90
+ });
91
+ app.use('/', express_1.default.static(outputDir));
92
+ server.listen(port);
93
+ console.log(`Server running at ${chalk_1.default.bold(chalk_1.default.green(`http://${ipAddress}:${port}`))}`);
94
+ console.log(`Use the Scripting app to scan the QR code below to install:`);
95
+ qrcode_terminal_1.default.generate(`http://${ipAddress}:${port}`, { small: true });
96
+ }
34
97
  }
35
98
  exports.buildApp = buildApp;
36
- function createAppFile() {
37
- const appFile = `${Object.keys(webpack_config_1.default.entry)[0]}.zip`;
38
- console.log(` ~ Creating ${appFile}....`);
39
- (0, cross_zip_1.zip)(node_path_1.default.resolve(process.cwd(), './build'), node_path_1.default.resolve(process.cwd(), `./build/${appFile}`), (error) => {
40
- if (error != null) {
41
- console.log(chalk_1.default.red('Error zipping app files: \n') + error);
42
- }
43
- else {
44
- console.log(chalk_1.default.green(` ✔️ ${appFile} created.`));
45
- }
46
- });
47
- }
@@ -22,28 +22,28 @@ class AppJsonPlugin {
22
22
  // 确保所有资源已被插件添加到 compilation
23
23
  stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
24
24
  }, (assets) => {
25
- const appJson = {
25
+ const scriptJson = {
26
26
  name: '',
27
27
  index: '',
28
28
  hash: '',
29
29
  assets: Object.keys(assets),
30
30
  };
31
- const indexJs = appJson.assets.find(filePath => filePath.match(/\.js$/i) != null);
31
+ const indexJs = scriptJson.assets.find(filePath => filePath.match(/\.js$/i) != null);
32
32
  if (indexJs != null) {
33
33
  const [appName, ...others] = indexJs.split('/');
34
34
  const filePath = others[others.length - 1];
35
- appJson.name = appName;
36
- appJson.index = filePath;
37
- appJson.hash = filePath.replace('.js', '');
35
+ scriptJson.name = appName;
36
+ scriptJson.index = filePath;
37
+ scriptJson.hash = filePath.replace('.js', '');
38
38
  const indexJsSource = assets[indexJs];
39
- appJson.assets = [
40
- ...appJson.assets.filter(e => e !== indexJs),
39
+ scriptJson.assets = [
40
+ ...scriptJson.assets.filter(e => e !== indexJs),
41
41
  filePath,
42
42
  ];
43
43
  compilation.deleteAsset(indexJs);
44
44
  compilation.emitAsset(filePath, indexJsSource);
45
45
  }
46
- compilation.emitAsset('app.json', new RawSource(JSON.stringify(appJson, null, 2)));
46
+ compilation.emitAsset('script.json', new RawSource(JSON.stringify(scriptJson, null, 2)));
47
47
  // const appMap: {
48
48
  // [appName: string]: {
49
49
  // appName: string
@@ -76,7 +76,7 @@ class AppJsonPlugin {
76
76
  // })
77
77
  // Object.entries(appMap).forEach(([appName, content]) => {
78
78
  // compilation.emitAsset(
79
- // appName + '/app.json',
79
+ // appName + '/script.json',
80
80
  // new RawSource(JSON.stringify(content, null, 2))
81
81
  // )
82
82
  // })
@@ -7,89 +7,97 @@ const node_path_1 = __importDefault(require("node:path"));
7
7
  const node_fs_1 = __importDefault(require("node:fs"));
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
10
+ const webpack_1 = __importDefault(require("webpack"));
10
11
  const AppJsonPlugin_1 = __importDefault(require("./AppJsonPlugin"));
11
- const baseDir = process.cwd();
12
- const srcDir = node_path_1.default.resolve(baseDir, 'src');
13
- const buildDir = node_path_1.default.resolve(baseDir, 'build');
14
- const pkgPath = node_path_1.default.resolve(baseDir, 'package.json');
15
- if (!node_fs_1.default.existsSync(pkgPath)) {
16
- console.log(chalk_1.default.red('✖️ package.json not found.'));
17
- process.exit(404);
18
- }
19
- const pkg = JSON.parse(node_fs_1.default.readFileSync(pkgPath, 'utf8'));
20
- const entry = {
21
- [pkg.name]: node_path_1.default.join(srcDir, 'index.tsx'),
22
- };
23
- const config = {
24
- mode: 'production',
25
- entry,
26
- optimization: {
27
- moduleIds: 'deterministic',
28
- chunkIds: 'named',
29
- minimizer: [
30
- new terser_webpack_plugin_1.default({
31
- extractComments: false,
32
- terserOptions: {
33
- format: {
34
- comments: false,
12
+ function getConfig() {
13
+ const baseDir = process.cwd();
14
+ const srcDir = node_path_1.default.resolve(baseDir, 'src');
15
+ const outputDir = node_path_1.default.resolve(baseDir, 'build');
16
+ const pkgPath = node_path_1.default.resolve(baseDir, 'package.json');
17
+ if (!node_fs_1.default.existsSync(pkgPath)) {
18
+ console.log(chalk_1.default.red('✖️ package.json not found.'));
19
+ process.exit(404);
20
+ }
21
+ const pkg = JSON.parse(node_fs_1.default.readFileSync(pkgPath, 'utf8'));
22
+ const entry = {
23
+ [pkg.name]: node_path_1.default.join(srcDir, 'index.tsx'),
24
+ };
25
+ const config = {
26
+ mode: 'production',
27
+ entry,
28
+ optimization: {
29
+ moduleIds: 'deterministic',
30
+ chunkIds: 'named',
31
+ minimizer: [
32
+ new terser_webpack_plugin_1.default({
33
+ extractComments: false,
34
+ terserOptions: {
35
+ format: {
36
+ comments: false,
37
+ },
35
38
  },
39
+ }),
40
+ ],
41
+ },
42
+ module: {
43
+ rules: [
44
+ {
45
+ test: /\.tsx?$/,
46
+ use: 'ts-loader',
47
+ exclude: /node_modules/,
36
48
  },
37
- }),
38
- ],
39
- },
40
- module: {
41
- rules: [
42
- {
43
- test: /\.tsx?$/,
44
- use: 'ts-loader',
45
- exclude: /node_modules/,
46
- },
47
- {
48
- test: /\.(png|jpe?g|gif|svg)$/i,
49
- loader: 'file-loader',
50
- options: {
51
- name: '[path][contenthash:8].[ext]',
52
- outputPath: (url, resourcePath, context) => {
53
- // if (url.startsWith('src/app/')) {
54
- // return url.replace('src/app/', '')
55
- // }
56
- return url.replace('src/', '');
57
- // return url.replace(/src\/([^/]+)\//, '')
58
- },
59
- publicPath: (url, resourcePath, context) => {
60
- // console.log([url, resourcePath])
61
- // return url.replace(/.*src\/app\/(\w+\/)?/, '')
62
- // if (url.startsWith('src/app/')) {
63
- // return url.replace('src/app/', '')
64
- // }
65
- return url.replace('src/', '');
49
+ {
50
+ test: /\.(png|jpe?g|gif|svg)$/i,
51
+ loader: 'file-loader',
52
+ options: {
53
+ name: '[path][contenthash:8].[ext]',
54
+ outputPath: (url, resourcePath, context) => {
55
+ // if (url.startsWith('src/app/')) {
56
+ // return url.replace('src/app/', '')
57
+ // }
58
+ return url.replace('src/', '');
59
+ // return url.replace(/src\/([^/]+)\//, '')
60
+ },
61
+ publicPath: (url, resourcePath, context) => {
62
+ // console.log([url, resourcePath])
63
+ // return url.replace(/.*src\/app\/(\w+\/)?/, '')
64
+ // if (url.startsWith('src/app/')) {
65
+ // return url.replace('src/app/', '')
66
+ // }
67
+ return url.replace('src/', '');
68
+ },
66
69
  },
67
70
  },
68
- },
69
- ],
70
- },
71
- resolve: {
72
- extensions: ['.tsx', '.ts', '.js'],
73
- modules: [
74
- 'node_modules',
75
- srcDir,
71
+ ],
72
+ },
73
+ resolve: {
74
+ extensions: ['.tsx', '.ts', '.js'],
75
+ modules: [
76
+ 'node_modules',
77
+ srcDir,
78
+ ],
79
+ alias: {
80
+ '@': srcDir,
81
+ }
82
+ },
83
+ output: {
84
+ filename: '[name]/[contenthash:8].js',
85
+ // filename: '[contenthash:8].js',
86
+ path: outputDir,
87
+ clean: true,
88
+ },
89
+ plugins: [
90
+ new AppJsonPlugin_1.default(),
91
+ new webpack_1.default.BannerPlugin({
92
+ banner: 'const Scripting = require("scripting");',
93
+ raw: true
94
+ }),
76
95
  ],
77
- alias: {
78
- '@': srcDir,
96
+ devtool: false,
97
+ externals: {
98
+ 'scripting': 'Scripting',
79
99
  }
80
- },
81
- output: {
82
- filename: '[name]/[contenthash:8].js',
83
- // filename: '[contenthash:8].js',
84
- path: buildDir,
85
- clean: true,
86
- },
87
- plugins: [
88
- new AppJsonPlugin_1.default(),
89
- ],
90
- devtool: false,
91
- externals: {
92
- 'scripting': 'Scripting',
93
- }
94
- };
95
- exports.default = config;
100
+ };
101
+ return config;
102
+ }
103
+ exports.default = getConfig;
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.createScript = void 0;
16
+ const chalk_1 = __importDefault(require("chalk"));
17
+ const node_path_1 = __importDefault(require("node:path"));
18
+ const node_child_process_1 = require("node:child_process");
19
+ const node_fs_1 = __importDefault(require("node:fs"));
20
+ const promises_1 = require("node:fs/promises");
21
+ function getScriptDir(scriptName) {
22
+ return node_path_1.default.join(process.cwd(), scriptName);
23
+ }
24
+ function createScriptDir(scriptName) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const appDir = getScriptDir(scriptName);
27
+ if (node_fs_1.default.existsSync(appDir)) {
28
+ throw new Error(`Directory "./${scriptName}" already exists.`);
29
+ }
30
+ // const dir = path.resolve(appDir, 'src/svgs')
31
+ const srcDir = node_path_1.default.resolve(appDir, 'src');
32
+ const typesDir = node_path_1.default.resolve(appDir, 'types');
33
+ yield Promise.all([
34
+ (0, promises_1.mkdir)(srcDir, { recursive: true }),
35
+ (0, promises_1.mkdir)(typesDir, { recursive: true })
36
+ ]);
37
+ });
38
+ }
39
+ function createEntryFile(scriptName) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ console.log(` > Creating ${scriptName}/src/index.tsx ...`);
42
+ const filePath = node_path_1.default.join(getScriptDir(scriptName), '/src/index.tsx');
43
+ yield (0, promises_1.writeFile)(filePath, `import { Column, CupertinoNavigationBar, CupertinoPageScaffold, Text, Container, useCupertinoColors, navigator, GestureDetector, Script, Center, CupertinoButton, } from 'scripting'
44
+
45
+ function App() {
46
+ const cupertinoColors = useCupertinoColors()
47
+ const backgroundColor = cupertinoColors.systemBackground
48
+
49
+ return (
50
+ <CupertinoPageScaffold
51
+ navigationBar={
52
+ <CupertinoNavigationBar
53
+ middle={
54
+ <Text>My Script</Text>
55
+ }
56
+ backgroundColor={backgroundColor}
57
+ />
58
+ }
59
+ >
60
+ <Center>
61
+ <Text
62
+ color={cupertinoColors.label}
63
+ >Welcome to Scripting!</Text>
64
+ </Center>
65
+ </CupertinoPageScaffold>
66
+ )
67
+ }
68
+
69
+ async function run() {
70
+ const result = await navigator.push({
71
+ element: <App />
72
+ })
73
+
74
+ Script.exit(result)
75
+ }
76
+
77
+ run()
78
+ `, 'utf-8');
79
+ console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/src/index.tsx`));
80
+ });
81
+ }
82
+ function createPackageJson(scriptName) {
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ console.log(` > Creating ${scriptName}/package.json ...`);
85
+ const filePath = node_path_1.default.join(getScriptDir(scriptName), 'package.json');
86
+ yield (0, promises_1.writeFile)(filePath, `{
87
+ "name": "${scriptName}",
88
+ "version": "0.0.1",
89
+ "private": true,
90
+ "scripts": {
91
+ "dev": "npx scripting-cli dev",
92
+ "build": "npx scripting-cli build"
93
+ }
94
+ }`, 'utf-8');
95
+ console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/package.json`));
96
+ });
97
+ }
98
+ function createReadme(scriptName) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ console.log(` > Creating ${scriptName}/README.md ...`);
101
+ const filePath = node_path_1.default.join(getScriptDir(scriptName), 'README.md');
102
+ yield (0, promises_1.writeFile)(filePath, `# ${scriptName} - A Scripting script
103
+
104
+ ## Start dev server
105
+
106
+ \`npm run dev\`
107
+
108
+ ## Build App
109
+
110
+ \`npm run build\`
111
+ `, 'utf-8');
112
+ console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/README.md`));
113
+ });
114
+ }
115
+ function createTSConfig(scriptName) {
116
+ return __awaiter(this, void 0, void 0, function* () {
117
+ console.log(` > Creating ${scriptName}/tsconfig.json ...`);
118
+ const filePath = node_path_1.default.join(getScriptDir(scriptName), 'tsconfig.json');
119
+ yield (0, promises_1.writeFile)(filePath, `{
120
+ "compilerOptions": {
121
+ "target": "ESNext",
122
+ "lib": [
123
+ "esnext"
124
+ ],
125
+ "allowJs": true,
126
+ "strict": true,
127
+ "esModuleInterop": true,
128
+ "allowSyntheticDefaultImports": true,
129
+ "forceConsistentCasingInFileNames": true,
130
+ "noFallthroughCasesInSwitch": true,
131
+ "module": "CommonJS",
132
+ "skipLibCheck": true,
133
+ "jsx": "react",
134
+ "jsxFactory": "createElement",
135
+ "baseUrl": "src",
136
+ "typeRoots": ["./types"],
137
+ // "paths": {
138
+ // "@/*": [
139
+ // "src/*"
140
+ // ]
141
+ // }
142
+ },
143
+ "include": [
144
+ "src"
145
+ ],
146
+ }`, 'utf-8');
147
+ console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/tsconfig.json`));
148
+ });
149
+ }
150
+ function copyAsset(scriptName, fileName) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ console.log(` > Creating ${scriptName}/types/${fileName}.d.ts ...`);
153
+ yield (0, promises_1.copyFile)(node_path_1.default.join(__dirname, `../public/${fileName}.d.ts`), node_path_1.default.join(getScriptDir(scriptName), `types/${fileName}.d.ts`));
154
+ console.log(chalk_1.default.green(` ✔️ Created ${scriptName}/types/${fileName}.d.ts`));
155
+ });
156
+ }
157
+ function copyAssets(scriptName) {
158
+ return __awaiter(this, void 0, void 0, function* () {
159
+ yield copyAsset(scriptName, 'scripting');
160
+ yield copyAsset(scriptName, 'global');
161
+ yield copyAsset(scriptName, 'assets');
162
+ // console.log(` > Creating ${scriptName}/src/svgs/logo.svg ...`)
163
+ // await copyFile(
164
+ // path.join(__dirname, '../public/logo.svg'),
165
+ // path.join(getScriptDir(scriptName), 'src/svgs/logo.svg')
166
+ // )
167
+ // console.log(
168
+ // chalk.green(` ✔️ Created ${scriptName}/src/svgs/logo.svg`)
169
+ // )
170
+ });
171
+ }
172
+ function createVSCodeSettings(scriptName) {
173
+ return __awaiter(this, void 0, void 0, function* () {
174
+ const destDir = node_path_1.default.join(getScriptDir(scriptName), '.vscode');
175
+ if (!node_fs_1.default.existsSync(destDir)) {
176
+ yield (0, promises_1.mkdir)(destDir, { recursive: true });
177
+ }
178
+ yield (0, promises_1.copyFile)(node_path_1.default.join(__dirname, '../.vscode/settings.json'), node_path_1.default.join(destDir, 'settings.json'));
179
+ });
180
+ }
181
+ function installDeps(scriptName) {
182
+ console.log(` > cd ${scriptName} && npm i -D ts-loader typescript file-loader`);
183
+ (0, node_child_process_1.execSync)(`cd ${scriptName} && npm i -D ts-loader typescript file-loader`);
184
+ console.log(chalk_1.default.green(` ✔️ Scripting script ${chalk_1.default.bold(scriptName)} is ready!`));
185
+ }
186
+ function createScript(scriptName) {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ if (!/^[a-zA-Z]+[a-zA-Z0-9-_]+$/.test(scriptName)) {
189
+ console.log(chalk_1.default.red(`✖️ Invalid Scripting script name "${scriptName}"`));
190
+ return;
191
+ }
192
+ console.log(`Start creating ${scriptName} ...`);
193
+ try {
194
+ yield createScriptDir(scriptName);
195
+ yield createPackageJson(scriptName);
196
+ yield createTSConfig(scriptName);
197
+ yield createReadme(scriptName);
198
+ yield createEntryFile(scriptName);
199
+ yield copyAssets(scriptName);
200
+ yield createVSCodeSettings(scriptName);
201
+ installDeps(scriptName);
202
+ console.log(`All done! Run ${chalk_1.default.bold(chalk_1.default.green(`cd ${scriptName} && npm run dev`))} to start the dev server.`);
203
+ }
204
+ catch (e) {
205
+ console.log(chalk_1.default.red(`✖️ Create script failed: ${e.message}`));
206
+ }
207
+ });
208
+ }
209
+ exports.createScript = createScript;
package/dist/index.js CHANGED
@@ -6,19 +6,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const minimist_1 = __importDefault(require("minimist"));
8
8
  const startDevServer_1 = require("./startDevServer");
9
- const build_1 = require("./build");
10
- const createApp_1 = require("./createApp");
9
+ // import { buildApp } from './build'
10
+ const createScript_1 = require("./createScript");
11
11
  function run() {
12
12
  const args = (0, minimist_1.default)(process.argv.slice(2));
13
- // console.log(args)
14
13
  if (args['create'] != null) {
15
- (0, createApp_1.createApp)(args['create']);
14
+ (0, createScript_1.createScript)(args['create']);
16
15
  }
17
16
  else if (args._.includes('dev')) {
18
17
  (0, startDevServer_1.startDevServer)();
19
18
  }
20
- else if (args._.includes('build')) {
21
- (0, build_1.buildApp)();
22
- }
19
+ // else if (args._.includes('build')) {
20
+ // buildApp()
21
+ // }
23
22
  }
24
23
  run();
@@ -56,8 +56,9 @@ function startDevServer() {
56
56
  const io = new socket_io_1.Server(server);
57
57
  let isStarted = false;
58
58
  let connectedSockets = [];
59
- webpack_config_1.default.mode = 'development';
60
- const compiler = (0, webpack_1.default)(webpack_config_1.default);
59
+ const webpackConfig = (0, webpack_config_1.default)();
60
+ webpackConfig.mode = 'development';
61
+ const compiler = (0, webpack_1.default)(webpackConfig);
61
62
  console.log('Start running webpack compiler in watch mode...');
62
63
  compiler.watch({}, (err, stats) => {
63
64
  utils.clearConsole();
@@ -79,9 +80,9 @@ function startDevServer() {
79
80
  if (isStarted) {
80
81
  printDevServerAddress();
81
82
  console.log(chalk_1.default.gray(` ~ Sent update event to ${connectedSockets.length} client(s)`));
82
- const appJson = yield (0, promises_1.readFile)(node_path_1.default.resolve(process.cwd(), 'build/app.json'), 'utf-8');
83
+ const scriptJson = yield (0, promises_1.readFile)(node_path_1.default.resolve(process.cwd(), 'build/script.json'), 'utf-8');
83
84
  for (const socket of connectedSockets) {
84
- socket.emit('update', appJson);
85
+ socket.emit('update', scriptJson);
85
86
  }
86
87
  }
87
88
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scripting-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "This plugin include all the commands for developing scripting-js apps.",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {