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
|
||||
```
|
||||
``` bash
|
||||
$ node preprocessing.js -a
|
||||
To generate all operator assets for showcase page
|
||||
```
|
||||
``` bash
|
||||
$ O={operator_name} node preprocessing.js -i
|
||||
To initialize folder and config file for an operator
|
||||
```
|
||||
``` bash
|
||||
$ node preprocessing.js -d
|
||||
To generate directory.json
|
||||
```
|
||||
``` bash
|
||||
$ O={operator_name} pnpm run dev
|
||||
Live showcase page server for development
|
||||
```
|
||||
@@ -26,10 +34,6 @@ Live showcase page server for development
|
||||
$ O={operator_name} pnpm run build
|
||||
Build showcase webpage for an operator
|
||||
```
|
||||
``` bash
|
||||
$ node build_all.js
|
||||
Build showcase webpages for all operators
|
||||
```
|
||||
### 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
|
||||
|
||||
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 init from './lib/initializer.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
|
||||
const OPERATOR_NAME = process.env.O;
|
||||
const op = process.argv[2]
|
||||
|
||||
if (process.argv[1].endsWith('vite.js')) {
|
||||
mode = "VITE"
|
||||
} else {
|
||||
mode = "NODE"
|
||||
}
|
||||
assert(OPERATOR_NAME !== undefined, 'Please set the environment variable O to the operator name.')
|
||||
|
||||
if (mode === null) {
|
||||
console.log('Please set the environment variable O to the operator name.')
|
||||
console.log('Or use the -o flag to specify the operator name.')
|
||||
process.exit(1)
|
||||
switch (op) {
|
||||
case '-a':
|
||||
exec(config)
|
||||
process.exit(0)
|
||||
case '-d':
|
||||
directory(config, __dirname)
|
||||
process.exit(0)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
let __dirname
|
||||
__dirname = __dirname || path.dirname(fileURLToPath(import.meta.url))
|
||||
assert(OPERATOR_NAME !== undefined, 'Please set the environment variable O to the operator name.')
|
||||
|
||||
const config = getConfig(__dirname)
|
||||
const OPERATOR_SOURCE_FOLDER = path.join(__dirname, config.folder.operator)
|
||||
const OPERATOR_RELEASE_FOLDER = path.join(__dirname, config.folder.release, OPERATOR_NAME)
|
||||
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')
|
||||
if (mode === 'NODE') {
|
||||
|
||||
const op = process.argv[2]
|
||||
|
||||
switch (op) {
|
||||
case '-i':
|
||||
init(OPERATOR_NAME, __dirname, EXTRACTED_FOLDER)
|
||||
process.exit(0)
|
||||
case '-d':
|
||||
directory(config, __dirname)
|
||||
process.exit(0)
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user