create-oc 1.1.8 → 1.1.10
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/index.js +53 -12
- package/package.json +2 -2
- package/templates/elm/package.json +2 -2
- package/templates/es6/package.json +2 -2
- package/templates/preact/package.json +2 -2
- package/templates/react/package.json +2 -2
- package/templates/solid/package.json +2 -2
- package/templates/svelte/package.json +2 -2
- package/templates/vue/package.json +2 -2
package/index.js
CHANGED
|
@@ -4,29 +4,70 @@ import prompts from 'prompts';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { parseArgs } from 'node:util';
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
+
const MIN_NODE_VERSION = 20;
|
|
10
|
+
function checkNodeVersion() {
|
|
11
|
+
const nodeVersion = process.version;
|
|
12
|
+
const major = parseInt(nodeVersion.split('.')[0].slice(1));
|
|
13
|
+
if (major < MIN_NODE_VERSION) {
|
|
14
|
+
console.error(`Node.js version ${MIN_NODE_VERSION} or higher is required`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
checkNodeVersion();
|
|
20
|
+
|
|
21
|
+
const templateChoices = [
|
|
22
|
+
{ title: 'Vanilla', value: 'es6' },
|
|
23
|
+
{ title: 'React', value: 'react' },
|
|
24
|
+
{ title: 'Solid', value: 'solid' },
|
|
25
|
+
{ title: 'Preact', value: 'preact' },
|
|
26
|
+
{ title: 'Vue', value: 'vue' },
|
|
27
|
+
{ title: 'Svelte', value: 'svelte' },
|
|
28
|
+
{ title: 'Elm', value: 'elm' },
|
|
29
|
+
];
|
|
30
|
+
const templates = templateChoices.map((t) => t.value);
|
|
31
|
+
|
|
32
|
+
let {
|
|
33
|
+
values: { name: componentName, template },
|
|
34
|
+
} = parseArgs({
|
|
35
|
+
args: process.argv.slice(2),
|
|
36
|
+
options: {
|
|
37
|
+
name: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
},
|
|
40
|
+
template: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
if (template && !templates.includes(template)) {
|
|
46
|
+
template = null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let answers = await prompts([
|
|
9
50
|
{
|
|
10
|
-
type: 'text',
|
|
51
|
+
type: componentName ? null : 'text',
|
|
11
52
|
name: 'componentName',
|
|
12
53
|
message: 'Component name',
|
|
13
54
|
initial: 'oc-component',
|
|
14
55
|
},
|
|
15
56
|
{
|
|
16
|
-
type: 'select',
|
|
57
|
+
type: template ? null : 'select',
|
|
17
58
|
name: 'template',
|
|
18
59
|
message: 'Select a template',
|
|
19
|
-
choices:
|
|
20
|
-
{ title: 'Vanilla', value: 'es6' },
|
|
21
|
-
{ title: 'React', value: 'react' },
|
|
22
|
-
{ title: 'Solid', value: 'solid' },
|
|
23
|
-
{ title: 'Preact', value: 'preact' },
|
|
24
|
-
{ title: 'Vue', value: 'vue' },
|
|
25
|
-
{ title: 'Svelte', value: 'svelte' },
|
|
26
|
-
{ title: 'Elm', value: 'elm' },
|
|
27
|
-
],
|
|
60
|
+
choices: templateChoices,
|
|
28
61
|
},
|
|
29
62
|
]);
|
|
63
|
+
|
|
64
|
+
if (!componentName) {
|
|
65
|
+
componentName = answers.componentName;
|
|
66
|
+
}
|
|
67
|
+
if (!template) {
|
|
68
|
+
template = answers.template;
|
|
69
|
+
}
|
|
70
|
+
|
|
30
71
|
if (!componentName || !template) {
|
|
31
72
|
process.exit(1);
|
|
32
73
|
}
|
package/package.json
CHANGED
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@testing-library/react": "^14.0.0",
|
|
27
27
|
"@testing-library/user-event": "^14.4.3",
|
|
28
28
|
"jsdom": "^21.1.1",
|
|
29
|
-
"oc-server": "^2.0
|
|
30
|
-
"oc-template-preact-compiler": "^1.1.
|
|
29
|
+
"oc-server": "^2.1.0",
|
|
30
|
+
"oc-template-preact-compiler": "^1.1.5",
|
|
31
31
|
"preact": "^10.13.2",
|
|
32
32
|
"typescript": "5.0.2",
|
|
33
33
|
"vitest": "^0.29.7"
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@testing-library/user-event": "^14.4.3",
|
|
27
27
|
"@types/react": "^18.0.28",
|
|
28
28
|
"jsdom": "^21.1.1",
|
|
29
|
-
"oc-server": "^2.0
|
|
30
|
-
"oc-template-react-compiler": "^7.1.
|
|
29
|
+
"oc-server": "^2.1.0",
|
|
30
|
+
"oc-template-react-compiler": "^7.1.5",
|
|
31
31
|
"react": "18.3.1",
|
|
32
32
|
"react-dom": "18.3.1",
|
|
33
33
|
"typescript": "5.1.3",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@testing-library/jest-dom": "^6.5.0",
|
|
26
26
|
"@types/testing-library__jest-dom": "^5.14.5",
|
|
27
27
|
"jsdom": "^21.1.1",
|
|
28
|
-
"oc-server": "^2.0
|
|
29
|
-
"oc-template-solid-compiler": "^1.1.
|
|
28
|
+
"oc-server": "^2.1.0",
|
|
29
|
+
"oc-template-solid-compiler": "^1.1.5",
|
|
30
30
|
"solid-js": "^1.9.5",
|
|
31
31
|
"typescript": "5.5.4",
|
|
32
32
|
"vitest": "^2.0.5"
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"@tsconfig/svelte": "^5.0.4",
|
|
28
28
|
"@types/testing-library__jest-dom": "^5.14.5",
|
|
29
29
|
"jsdom": "^21.1.1",
|
|
30
|
-
"oc-server": "^2.0
|
|
31
|
-
"oc-template-svelte-compiler": "^0.0.
|
|
30
|
+
"oc-server": "^2.1.0",
|
|
31
|
+
"oc-template-svelte-compiler": "^0.0.7",
|
|
32
32
|
"svelte": "^5.23.0",
|
|
33
33
|
"typescript": "5.0.2",
|
|
34
34
|
"vitest": "^0.29.7"
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@vitejs/plugin-vue": "^5.2.1",
|
|
27
27
|
"@vue/tsconfig": "^0.7.0",
|
|
28
28
|
"jsdom": "^21.1.1",
|
|
29
|
-
"oc-server": "^2.0
|
|
30
|
-
"oc-template-vue-compiler": "^1.1.
|
|
29
|
+
"oc-server": "^2.1.0",
|
|
30
|
+
"oc-template-vue-compiler": "^1.1.5",
|
|
31
31
|
"typescript": "5.8.2",
|
|
32
32
|
"vitest": "^0.29.7",
|
|
33
33
|
"vue": "^3.5.13",
|