feat(preprocessing): combine build_all and preprocessing
This commit is contained in:
12
README.md
12
README.md
@@ -15,10 +15,18 @@ $ O={operator_name} node preprocessing.js
|
|||||||
To generate operator assets for showcase page
|
To generate operator assets for showcase page
|
||||||
```
|
```
|
||||||
``` bash
|
``` bash
|
||||||
|
$ node preprocessing.js -a
|
||||||
|
To generate all operator assets for showcase page
|
||||||
|
```
|
||||||
|
``` bash
|
||||||
$ O={operator_name} node preprocessing.js -i
|
$ O={operator_name} node preprocessing.js -i
|
||||||
To initialize folder and config file for an operator
|
To initialize folder and config file for an operator
|
||||||
```
|
```
|
||||||
``` bash
|
``` bash
|
||||||
|
$ node preprocessing.js -d
|
||||||
|
To generate directory.json
|
||||||
|
```
|
||||||
|
``` bash
|
||||||
$ O={operator_name} pnpm run dev
|
$ O={operator_name} pnpm run dev
|
||||||
Live showcase page server for development
|
Live showcase page server for development
|
||||||
```
|
```
|
||||||
@@ -26,10 +34,6 @@ Live showcase page server for development
|
|||||||
$ O={operator_name} pnpm run build
|
$ O={operator_name} pnpm run build
|
||||||
Build showcase webpage for an operator
|
Build showcase webpage for an operator
|
||||||
```
|
```
|
||||||
``` bash
|
|
||||||
$ node build_all.js
|
|
||||||
Build showcase webpages for all operators
|
|
||||||
```
|
|
||||||
### Webpage & JavaScript
|
### Webpage & JavaScript
|
||||||
|
|
||||||
Add query string `settings` to bring up the settings panel to adjust your settings. Then use appropriate JavaScript code to load your settings
|
Add query string `settings` to bring up the settings panel to adjust your settings. Then use appropriate JavaScript code to load your settings
|
||||||
|
|||||||
15
build_all.js
15
build_all.js
@@ -1,15 +0,0 @@
|
|||||||
import path from 'path'
|
|
||||||
import fs from 'fs'
|
|
||||||
import { execSync } from 'child_process'
|
|
||||||
import { fileURLToPath } from 'url'
|
|
||||||
|
|
||||||
let __dirname
|
|
||||||
__dirname = __dirname || path.dirname(fileURLToPath(import.meta.url))
|
|
||||||
|
|
||||||
const directory = path.join(__dirname, 'operator');
|
|
||||||
fs.readdir(directory, function (err, files) {
|
|
||||||
files.forEach(function (file) {
|
|
||||||
if (file.startsWith('_')) return;
|
|
||||||
console.log(execSync(`O=${file} node preprocessing.js && O=${file} pnpm run build`).toString());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
8
lib/exec.js
Normal file
8
lib/exec.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import { execSync } from 'child_process'
|
||||||
|
|
||||||
|
export default function (config) {
|
||||||
|
for (const [key, _] of Object.entries(config.operators)) {
|
||||||
|
if (key.startsWith('_')) break;
|
||||||
|
console.log(execSync(`O=${key} node preprocessing.js && O=${key} pnpm run build`).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,26 +8,35 @@ import path from 'path'
|
|||||||
import { fileURLToPath } from 'url'
|
import { fileURLToPath } from 'url'
|
||||||
import init from './lib/initializer.js'
|
import init from './lib/initializer.js'
|
||||||
import directory from './lib/directory.js'
|
import directory from './lib/directory.js'
|
||||||
|
import exec from './lib/exec.js'
|
||||||
|
|
||||||
|
let __dirname
|
||||||
|
__dirname = __dirname || path.dirname(fileURLToPath(import.meta.url))
|
||||||
|
const config = getConfig(__dirname)
|
||||||
|
|
||||||
let mode = null
|
let mode = null
|
||||||
const OPERATOR_NAME = process.env.O;
|
const OPERATOR_NAME = process.env.O;
|
||||||
|
const op = process.argv[2]
|
||||||
|
|
||||||
if (process.argv[1].endsWith('vite.js')) {
|
if (process.argv[1].endsWith('vite.js')) {
|
||||||
mode = "VITE"
|
mode = "VITE"
|
||||||
} else {
|
} else {
|
||||||
mode = "NODE"
|
mode = "NODE"
|
||||||
}
|
}
|
||||||
assert(OPERATOR_NAME !== undefined, 'Please set the environment variable O to the operator name.')
|
|
||||||
|
|
||||||
if (mode === null) {
|
switch (op) {
|
||||||
console.log('Please set the environment variable O to the operator name.')
|
case '-a':
|
||||||
console.log('Or use the -o flag to specify the operator name.')
|
exec(config)
|
||||||
process.exit(1)
|
process.exit(0)
|
||||||
|
case '-d':
|
||||||
|
directory(config, __dirname)
|
||||||
|
process.exit(0)
|
||||||
|
default:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
let __dirname
|
assert(OPERATOR_NAME !== undefined, 'Please set the environment variable O to the operator name.')
|
||||||
__dirname = __dirname || path.dirname(fileURLToPath(import.meta.url))
|
|
||||||
|
|
||||||
const config = getConfig(__dirname)
|
|
||||||
const OPERATOR_SOURCE_FOLDER = path.join(__dirname, config.folder.operator)
|
const OPERATOR_SOURCE_FOLDER = path.join(__dirname, config.folder.operator)
|
||||||
const OPERATOR_RELEASE_FOLDER = path.join(__dirname, config.folder.release, OPERATOR_NAME)
|
const OPERATOR_RELEASE_FOLDER = path.join(__dirname, config.folder.release, OPERATOR_NAME)
|
||||||
const SHOWCASE_PUBLIC_FOLDER = path.join(__dirname, "public")
|
const SHOWCASE_PUBLIC_FOLDER = path.join(__dirname, "public")
|
||||||
@@ -36,15 +45,10 @@ const EXTRACTED_FOLDER = path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, 'extra
|
|||||||
const OPERATOR_SHARE_FOLDER = path.join(OPERATOR_SOURCE_FOLDER, '_share')
|
const OPERATOR_SHARE_FOLDER = path.join(OPERATOR_SOURCE_FOLDER, '_share')
|
||||||
if (mode === 'NODE') {
|
if (mode === 'NODE') {
|
||||||
|
|
||||||
const op = process.argv[2]
|
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case '-i':
|
case '-i':
|
||||||
init(OPERATOR_NAME, __dirname, EXTRACTED_FOLDER)
|
init(OPERATOR_NAME, __dirname, EXTRACTED_FOLDER)
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
case '-d':
|
|
||||||
directory(config, __dirname)
|
|
||||||
process.exit(0)
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user