@bwog/create-bwog 0.0.0-stage → 0.1.0
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/build.js +16 -0
- package/create-bwog.js +33 -0
- package/package.json +26 -6
- package/templates/cloudflare-worker/bwog.config.js +5 -0
- package/templates/cloudflare-worker/package-lock.json +3471 -0
- package/templates/cloudflare-worker/package.json +12 -0
- package/templates/cloudflare-worker/wrangler.jsonc +72 -0
- package/templates/vps/.env +15 -0
- package/templates/vps/bwog.config.js +5 -0
- package/templates/vps/package-lock.json +2011 -0
- package/templates/vps/package.json +11 -0
- package/README.md +0 -3
package/build.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { cpSync } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
const copyFilesList = [
|
|
5
|
+
['wrangler.jsonc', 'cloudflare-worker/wrangler.jsonc'],
|
|
6
|
+
['bwog.config.js', 'cloudflare-worker/bwog.config.js'],
|
|
7
|
+
['.env.example', 'vps/.env'],
|
|
8
|
+
['bwog.config.js', 'vps/bwog.config.js'],
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
copyFilesList.forEach(copyFile => {
|
|
12
|
+
cpSync(
|
|
13
|
+
resolve('./node_modules/bwog/', copyFile[0]),
|
|
14
|
+
resolve('./templates/', copyFile[1])
|
|
15
|
+
);
|
|
16
|
+
})
|
package/create-bwog.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { cpSync, opendirSync } from 'node:fs';
|
|
5
|
+
import { program, Option } from 'commander';
|
|
6
|
+
|
|
7
|
+
program
|
|
8
|
+
.description('Create new bwog app')
|
|
9
|
+
.addOption(new Option('-t, --template <string>', 'type of deployment: cloudflare workers or a traditional web server.').choices(['cloudflare-worker', 'vps']).makeOptionMandatory())
|
|
10
|
+
.option('-d, --destination <string>', 'location where app should be set up', './')
|
|
11
|
+
.option('-f, --overwrite', 'merge files with destination directory, overwriting files with the same names');
|
|
12
|
+
program.parse();
|
|
13
|
+
|
|
14
|
+
const options = program.opts();
|
|
15
|
+
const template = resolve(import.meta.dirname, `./templates/${options.template}`);
|
|
16
|
+
const destination = options.destination;
|
|
17
|
+
const overwrite = options.overwrite;
|
|
18
|
+
|
|
19
|
+
if (!overwrite) {
|
|
20
|
+
const dir = opendirSync(destination);
|
|
21
|
+
const entry = dir.read();
|
|
22
|
+
await dir.close();
|
|
23
|
+
if (entry !== null) {
|
|
24
|
+
console.error(`Destination directory '${destination}' is not empty. Set '--overwrite' to continue anyway.`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
console.log(`Creating bwog app at ${destination}`);
|
|
29
|
+
try {
|
|
30
|
+
cpSync(template, destination, {recursive: true});
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error(`Failed to create app at ${destination}: ${error}`);
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bwog/create-bwog",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@bwog/create-bwog",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Package for initializing a new bwog app",
|
|
5
|
+
"author": "Chase Patterson (https://github.com/chapatt)",
|
|
6
|
+
"homepage": "https://github.com/chapatt/bwog",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/chapatt/create-bwog.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": "https://github.com/chapatt/create-bwog/issues",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=22.23.5"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@bwog/bwog": "^0.1.0"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "node build.js"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"create-bwog": "./create-bwog.js"
|
|
25
|
+
}
|
|
26
|
+
}
|