@bonsae/create-nrg 0.5.0 → 0.6.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/LICENSE +21 -0
- package/README.md +4 -2
- package/{dist/index.js → index.js} +2 -1
- package/package.json +16 -9
- package/{dist/scaffold.js → scaffold.js} +1 -1
- package/templates/node/schema.ts.hbs +16 -1
- package/templates/node/server-index.ts.hbs +3 -2
- package/templates/project/.gitignore.hbs +1 -0
- package/templates/project/.husky/pre-push.hbs +1 -0
- package/templates/project/package.json.hbs +18 -11
- package/templates/project/src/server/tsconfig.json.hbs +1 -1
- package/templates/project/vitest.server.unit.config.ts.hbs +11 -0
- package/templates/project/vitest.config.ts.hbs +0 -7
- /package/templates/project/{commitlint.config.js.hbs → commitlint.config.ts.hbs} +0 -0
- /package/templates/project/{eslint.config.js.hbs → eslint.config.ts.hbs} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Allan Oricil
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="https://www.npmjs.com/package/@bonsae/create-nrg"><img src="https://img.shields.io/npm/v/@bonsae/create-nrg.svg" alt="npm package"></a>
|
|
7
7
|
<a href="https://github.com/bonsaedev/create-nrg/actions/workflows/ci.yaml"><img src="https://github.com/bonsaedev/create-nrg/actions/workflows/ci.yaml/badge.svg?branch=main" alt="build status"></a>
|
|
8
|
+
<a href="https://codecov.io/gh/bonsaedev/create-nrg"><img src="https://codecov.io/gh/bonsaedev/create-nrg/graph/badge.svg" alt="codecov"/></a>
|
|
9
|
+
<a href="https://socket.dev/npm/package/@bonsae/create-nrg"><img src="https://badge.socket.dev/npm/package/@bonsae/create-nrg" alt="Socket Badge"></a>
|
|
8
10
|
</p>
|
|
9
11
|
|
|
10
12
|
# create-nrg
|
|
@@ -42,8 +44,8 @@ my-project/
|
|
|
42
44
|
├── .husky/
|
|
43
45
|
├── .gitignore
|
|
44
46
|
├── .prettierrc.json
|
|
45
|
-
├── eslint.config.
|
|
46
|
-
├── commitlint.config.
|
|
47
|
+
├── eslint.config.ts
|
|
48
|
+
├── commitlint.config.ts
|
|
47
49
|
├── package.json
|
|
48
50
|
├── tsconfig.json
|
|
49
51
|
├── vite.config.ts
|
|
@@ -6,7 +6,7 @@ import { fileURLToPath } from "node:url";
|
|
|
6
6
|
import { dashCase, scaffoldProject } from "./scaffold.js";
|
|
7
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
8
|
const __dirname = path.dirname(__filename);
|
|
9
|
-
const TEMPLATES_DIR = path.resolve(__dirname, "
|
|
9
|
+
const TEMPLATES_DIR = path.resolve(__dirname, "templates");
|
|
10
10
|
export function parseArgs(argv) {
|
|
11
11
|
const result = {};
|
|
12
12
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -34,6 +34,7 @@ export function parseArgs(argv) {
|
|
|
34
34
|
}
|
|
35
35
|
return result;
|
|
36
36
|
}
|
|
37
|
+
/* v8 ignore start -- interactive CLI entry point, tested via cli.test.ts subprocess */
|
|
37
38
|
async function main() {
|
|
38
39
|
p.intro("Create a new NRG project");
|
|
39
40
|
const args = process.argv.slice(2);
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonsae/create-nrg",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Scaffold a new NRG project for Node-RED",
|
|
5
5
|
"author": "Allan Oricil <allanoricil@duck.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"create-nrg": "./
|
|
9
|
+
"create-nrg": "./index.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"
|
|
12
|
+
"index.js",
|
|
13
|
+
"scaffold.js",
|
|
13
14
|
"templates/"
|
|
14
15
|
],
|
|
15
16
|
"publishConfig": {
|
|
16
|
-
"access": "public"
|
|
17
|
+
"access": "public",
|
|
18
|
+
"directory": "dist"
|
|
17
19
|
},
|
|
18
20
|
"engines": {
|
|
19
21
|
"node": ">=22"
|
|
@@ -30,14 +32,18 @@
|
|
|
30
32
|
"bonsae"
|
|
31
33
|
],
|
|
32
34
|
"scripts": {
|
|
33
|
-
"build": "tsc",
|
|
35
|
+
"build": "tsc && node -e \"const fs=require('fs');fs.cpSync('src/templates','dist/templates',{recursive:true});for(const f of['package.json','README.md','LICENSE'])fs.copyFileSync(f,'dist/'+f)\"",
|
|
34
36
|
"dev": "tsc --watch",
|
|
35
|
-
"
|
|
37
|
+
"validate": "pnpm validate:lint && pnpm validate:format",
|
|
38
|
+
"validate:lint": "eslint src/",
|
|
39
|
+
"validate:format": "prettier --check \"src/**/*.ts\"",
|
|
36
40
|
"lint:fix": "eslint src/ --fix",
|
|
37
41
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
38
|
-
"
|
|
39
|
-
"test": "vitest run",
|
|
40
|
-
"test:watch": "vitest",
|
|
42
|
+
"test": "pnpm test:unit",
|
|
43
|
+
"test:unit": "vitest run --config vitest.unit.config.ts",
|
|
44
|
+
"test:unit:watch": "vitest --config vitest.unit.config.ts",
|
|
45
|
+
"test:e2e": "vitest run --config vitest.e2e.config.ts",
|
|
46
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
41
47
|
"prepare": "husky"
|
|
42
48
|
},
|
|
43
49
|
"dependencies": {
|
|
@@ -54,6 +60,7 @@
|
|
|
54
60
|
"@types/node": "^22.15.18",
|
|
55
61
|
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
56
62
|
"@typescript-eslint/parser": "^8.32.1",
|
|
63
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
57
64
|
"eslint": "^9.27.0",
|
|
58
65
|
"eslint-config-prettier": "^10.1.8",
|
|
59
66
|
"husky": "^9.1.7",
|
|
@@ -15,7 +15,7 @@ export function pascalCase(str) {
|
|
|
15
15
|
}
|
|
16
16
|
export function renderTemplate(content, vars) {
|
|
17
17
|
const template = Handlebars.compile(content, { noEscape: true });
|
|
18
|
-
return template(vars);
|
|
18
|
+
return template(vars).replace(/\r\n/g, "\n");
|
|
19
19
|
}
|
|
20
20
|
export function copyTemplateDir(srcDir, destDir, vars) {
|
|
21
21
|
const entries = fs.readdirSync(srcDir, { withFileTypes: true });
|
|
@@ -55,4 +55,19 @@ const SettingsSchema = defineSchema(
|
|
|
55
55
|
},
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
-
export {
|
|
58
|
+
export {
|
|
59
|
+
ConfigsSchema,
|
|
60
|
+
CredentialsSchema,
|
|
61
|
+
{{#if hasInputs}}
|
|
62
|
+
InputSchema,
|
|
63
|
+
{{/if}}
|
|
64
|
+
{{#if hasSingleOutput}}
|
|
65
|
+
OutputSchema,
|
|
66
|
+
{{/if}}
|
|
67
|
+
{{#if hasMultipleOutputs}}
|
|
68
|
+
{{#each outputPorts}}
|
|
69
|
+
OutputPort{{index}}Schema,
|
|
70
|
+
{{/each}}
|
|
71
|
+
{{/if}}
|
|
72
|
+
SettingsSchema,
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pnpm build && pnpm validate && pnpm test
|
|
@@ -14,18 +14,20 @@
|
|
|
14
14
|
"nrg"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"debug": "
|
|
18
|
-
"dev": "
|
|
19
|
-
"build:dev": "
|
|
20
|
-
"build": "
|
|
21
|
-
"
|
|
17
|
+
"debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode development",
|
|
18
|
+
"dev": "vite --mode development",
|
|
19
|
+
"build:dev": "vite build --mode development",
|
|
20
|
+
"build": "vite build --mode production",
|
|
21
|
+
"validate": "pnpm validate:tsc && pnpm validate:lint && pnpm validate:format",
|
|
22
|
+
"validate:tsc": "tsc -p src/server/tsconfig.json --noEmit",
|
|
23
|
+
"validate:lint": "eslint src/",
|
|
24
|
+
"validate:format": "prettier --check \"src/**/*.{ts,vue,json}\"",
|
|
22
25
|
"lint:fix": "eslint src/ --fix",
|
|
23
26
|
"format": "prettier --write \"src/**/*.{ts,vue,json}\"",
|
|
24
|
-
"
|
|
25
|
-
"test": "
|
|
26
|
-
"test:
|
|
27
|
-
"
|
|
28
|
-
"tsc:server": "tsc -p src/server/tsconfig.json",
|
|
27
|
+
"test": "pnpm test:server",
|
|
28
|
+
"test:server": "pnpm test:server:unit",
|
|
29
|
+
"test:server:unit": "vitest run --config vitest.server.unit.config.ts",
|
|
30
|
+
"test:server:unit:watch": "vitest --config vitest.server.unit.config.ts",
|
|
29
31
|
"prepare": "husky"
|
|
30
32
|
},
|
|
31
33
|
"lint-staged": {
|
|
@@ -33,6 +35,9 @@
|
|
|
33
35
|
"eslint --fix",
|
|
34
36
|
"prettier --write"
|
|
35
37
|
],
|
|
38
|
+
"tests/**/*.ts": [
|
|
39
|
+
"prettier --write"
|
|
40
|
+
],
|
|
36
41
|
"src/**/*.json": [
|
|
37
42
|
"prettier --write"
|
|
38
43
|
]
|
|
@@ -53,11 +58,13 @@
|
|
|
53
58
|
"globals": "^16.1.0",
|
|
54
59
|
"husky": "^9.1.7",
|
|
55
60
|
"lint-staged": "^16.4.0",
|
|
61
|
+
"node-red": "latest",
|
|
56
62
|
"prettier": "^3.5.3",
|
|
63
|
+
"tsx": "^4.22.4",
|
|
57
64
|
"typescript": "^5.8.3",
|
|
58
65
|
"typescript-eslint": "^8.32.1",
|
|
59
66
|
"vite": "^6.3.4",
|
|
60
67
|
"vitest": "^4.1.5",
|
|
61
|
-
"vue": "^3.5.
|
|
68
|
+
"vue": "^3.5.34"
|
|
62
69
|
}
|
|
63
70
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineConfig, mergeConfig } from "vitest/config";
|
|
2
|
+
import { defaultConfig } from "@bonsae/nrg/test/server/unit/config";
|
|
3
|
+
|
|
4
|
+
export default mergeConfig(
|
|
5
|
+
defaultConfig,
|
|
6
|
+
defineConfig({
|
|
7
|
+
test: {
|
|
8
|
+
include: ["tests/server/**/*.test.ts"],
|
|
9
|
+
},
|
|
10
|
+
}),
|
|
11
|
+
);
|
|
File without changes
|
|
File without changes
|