create-ui0 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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,103 @@
1
+ import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import prompts from 'prompts';
5
+ /**
6
+ * create-ui0 - scaffolds a ui0 (Vue + @ui0 packages) app.
7
+ * Usage: npm create ui0 [dir]
8
+ */
9
+ const templateDir = fileURLToPath(new URL('../template', import.meta.url));
10
+ /** selectable template features - each adds deps (and a demo section) */
11
+ const FEATURES = [
12
+ {
13
+ id: 'flex',
14
+ title: 'Flex layout',
15
+ deps: { '@ui0/flex': '^0.1.1' },
16
+ importLine: "import Flex from '@ui0/flex'",
17
+ section: ` <section>
18
+ <h2>Flex</h2>
19
+ <Flex items="center">
20
+ <div :class="$style.box">one</div>
21
+ <div :class="$style.box">two</div>
22
+ <div :class="$style.box">three</div>
23
+ </Flex>
24
+ </section>`
25
+ },
26
+ {
27
+ id: 'button',
28
+ title: 'Button component',
29
+ deps: { '@ui0/button': '^0.1.1' },
30
+ importLine: "import Button from '@ui0/button'",
31
+ section: ` <section>
32
+ <h2>Button</h2>
33
+ <Button>default</Button>
34
+ </section>`
35
+ },
36
+ {
37
+ id: 'icon',
38
+ title: 'Icon component + ui0 icon pack',
39
+ deps: { '@ui0/icon': '^0.1.1', '@ui0/icons': '^0.1.1' },
40
+ importLine: "import { Icon } from '@ui0/icon'",
41
+ section: ` <section>
42
+ <h2>Icon</h2>
43
+ <Icon value="ui0/heart-alt" />
44
+ </section>`
45
+ }
46
+ ];
47
+ const onCancel = () => {
48
+ console.log('aborted');
49
+ process.exit(0);
50
+ };
51
+ const run = async () => {
52
+ const argDir = process.argv[2];
53
+ const { dir } = await prompts({
54
+ type: argDir ? null : 'text',
55
+ name: 'dir',
56
+ message: 'Project directory',
57
+ initial: 'ui0-app'
58
+ }, { onCancel });
59
+ const target = path.resolve(process.cwd(), argDir ?? dir);
60
+ const name = path.basename(target);
61
+ if (existsSync(target)) {
62
+ const { overwrite } = await prompts({ type: 'confirm', name: 'overwrite', message: `${name} exists - continue and fill missing files?`, initial: false }, { onCancel });
63
+ if (!overwrite)
64
+ process.exit(0);
65
+ }
66
+ const { features } = (await prompts({
67
+ type: 'multiselect',
68
+ name: 'features',
69
+ message: 'Packages to include',
70
+ choices: FEATURES.map((f) => ({ title: f.title, value: f.id, selected: f.id !== 'icon' })),
71
+ instructions: false
72
+ }, { onCancel }));
73
+ mkdirSync(target, { recursive: true });
74
+ cpSync(templateDir, target, { recursive: true });
75
+ rmSync(path.join(target, 'package.json.tpl'));
76
+ const picked = FEATURES.filter((f) => features.includes(f.id));
77
+ // package.json from the template manifest + chosen deps
78
+ const manifest = JSON.parse(readFileSync(path.join(templateDir, 'package.json.tpl'), 'utf8'));
79
+ manifest.name = name;
80
+ Object.assign(manifest.dependencies, ...picked.map((f) => f.deps));
81
+ writeFileSync(path.join(target, 'package.json'), JSON.stringify(manifest, null, 2) + '\n');
82
+ // App.vue: inject the demo sections of the picked features
83
+ const appVue = path.join(target, 'src/App.vue');
84
+ let app = readFileSync(appVue, 'utf8');
85
+ app = app
86
+ .replace('/* FEATURE_IMPORTS */', picked.map((f) => f.importLine).join('\n'))
87
+ .replace('/* FEATURE_SECTIONS */', picked.map((f) => f.section).join('\n\n'));
88
+ writeFileSync(appVue, app);
89
+ // the icon pack registers itself as a vue plugin
90
+ const mainTs = path.join(target, 'src/main.ts');
91
+ let main = readFileSync(mainTs, 'utf8');
92
+ if (features.includes('icon')) {
93
+ main = main
94
+ .replace("import { createUi0 } from '@ui0/core'", "import Icons from '@ui0/icons'\nimport { createUi0 } from '@ui0/core'")
95
+ .replace('app.use(ui0)', 'app.use(ui0)\napp.use(Icons)');
96
+ }
97
+ writeFileSync(mainTs, main);
98
+ console.log(`\nScaffolded ${name}:\n`);
99
+ console.log(` cd ${path.relative(process.cwd(), target)}`);
100
+ console.log(' npm install');
101
+ console.log(' npm run dev');
102
+ };
103
+ run();
package/package.json CHANGED
@@ -1,6 +1,25 @@
1
1
  {
2
2
  "name": "create-ui0",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Scaffold a ui0 (Vue + @ui0) app - npm create ui0",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-ui0": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "template"
12
+ ],
13
+ "scripts": {
14
+ "create:build": "tsc -p tsconfig.json",
15
+ "create:publish": "npm publish --access public"
16
+ },
17
+ "dependencies": {
18
+ "prompts": "^2.4.2"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^20.14.8",
22
+ "@types/prompts": "^2.4.9",
23
+ "typescript": "~6.0.3"
24
+ }
25
+ }
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>ui0 app</title>
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/src/main.ts"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "ui0-app",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "vue": "^3.5.45",
13
+ "@ui0/core": "^0.1.2",
14
+ "@ui0/theme": "^0.1.1"
15
+ },
16
+ "devDependencies": {
17
+ "@ui0/types": "^0.1.2",
18
+ "@vitejs/plugin-vue": "^6.0.1",
19
+ "sass-embedded": "^1.80.0",
20
+ "vite": "^8.3.5"
21
+ }
22
+ }
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <ThemeProvider preset="app">
3
+ <App
4
+ title="ui0 app"
5
+ name="app"
6
+ >
7
+ <main :class="$style.page">
8
+ <h1>ui0 app</h1>
9
+
10
+ /* FEATURE_SECTIONS */
11
+ </main>
12
+ </App>
13
+ </ThemeProvider>
14
+ </template>
15
+
16
+ <script setup lang="ts">
17
+ import { App } from '@ui0/core'
18
+ import { ThemeProvider } from '@ui0/theme'
19
+ /* FEATURE_IMPORTS */
20
+ </script>
21
+
22
+ <style module lang="scss">
23
+ .page {
24
+ display: flex;
25
+ flex-direction: column;
26
+ gap: 24px;
27
+ padding: 32px;
28
+ font-family: system-ui, sans-serif;
29
+
30
+ h1 {
31
+ font-size: 20px;
32
+ }
33
+ h2 {
34
+ font-size: 14px;
35
+ opacity: 0.7;
36
+ margin-bottom: 8px;
37
+ }
38
+ }
39
+ .box {
40
+ padding: 12px 16px;
41
+ border: 1px solid rgba(127, 127, 127, 0.4);
42
+ border-radius: 6px;
43
+ }
44
+ </style>
@@ -0,0 +1,14 @@
1
+ import { createUi0 } from '@ui0/core'
2
+ import { createUi0Theme } from '@ui0/theme'
3
+ import { createApp } from 'vue'
4
+
5
+ import './assets/theme.css'
6
+ import config from '../ui0.config'
7
+ import App from './App.vue'
8
+
9
+ const ui0 = createUi0(config)
10
+ ui0.use(createUi0Theme(config.theme!))
11
+
12
+ const app = createApp(App)
13
+ app.use(ui0)
14
+ app.mount('#app')
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "jsx": "preserve",
8
+ "types": ["vue"],
9
+ "noEmit": true
10
+ },
11
+ "include": ["src/**/*.ts", "src/**/*.vue", "vite.config.ts", "ui0.config.ts"]
12
+ }
@@ -0,0 +1,23 @@
1
+ import type { Ui0CoreConfig } from '@ui0/types'
2
+
3
+ const config: Ui0CoreConfig = {
4
+ theme: {
5
+ default: 'app',
6
+ contracts: {
7
+ display: {}
8
+ },
9
+ presets: {
10
+ app: {
11
+ default: {
12
+ color: {
13
+ brand: ['rgb(86 59 177)', 4],
14
+ foreground: '#111',
15
+ background: '#fff'
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
22
+
23
+ export default config
@@ -0,0 +1,7 @@
1
+ import ui0Theme from '@ui0/theme/vite'
2
+ import Vue from '@vitejs/plugin-vue'
3
+ import { defineConfig } from 'vite'
4
+
5
+ export default defineConfig({
6
+ plugins: [ui0Theme({ out: 'src/assets/theme.css' }), Vue()]
7
+ })
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.