@sidekick-coder/zenith-kit 0.0.11 → 0.0.13
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/bin/zenith.js +28 -0
- package/bin/zkit.js +26 -0
- package/cli/commands/build.js +49 -0
- package/cli/commands/dev.js +37 -0
- package/cli/commands/start.js +38 -0
- package/cli/config.js +23 -0
- package/cli/utils/createWrapper.js +20 -0
- package/dist/client/index.d.mts +448 -0
- package/dist/client/index.mjs +2 -0
- package/dist/components/index-Dk5fhUBV.mjs +4399 -0
- package/dist/components/index.es.js +65708 -0
- package/dist/components/styles.css +4756 -0
- package/dist/server/index.d.mts +776 -178
- package/dist/server/index.mjs +5 -1743
- package/dist/shared/chunk-0Lt9GpW0.mjs +1 -0
- package/dist/shared/index.d.mts +266 -21
- package/dist/shared/index.mjs +2 -856
- package/package.json +66 -13
- package/tsconfig.client.json +3 -3
- package/tsconfig.server.json +1 -1
- package/tsdown/createTsdownConfig.js +29 -0
- package/tsdown.config.ts +53 -3
- package/vite/createViteConfig.js +55 -0
- package/vite/plugins/zenith.js +143 -0
- package/vite.config.ts +71 -0
- package/dist/shared/chunk-CfYAbeIz.mjs +0 -13
package/bin/zenith.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import createWrapper from '../cli/utils/createWrapper.js'
|
|
3
|
+
import { EnvService } from '../dist/server/index.mjs'
|
|
4
|
+
import { BaseException } from '../dist/shared/index.mjs'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
import { kitConfig } from '../cli/config.js'
|
|
7
|
+
|
|
8
|
+
const cwd = process.cwd()
|
|
9
|
+
const id = kitConfig.module_id
|
|
10
|
+
|
|
11
|
+
EnvService.dotEnvConfig({
|
|
12
|
+
path: path.join(cwd, '.env'),
|
|
13
|
+
quiet: true
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
if (!process.env.ZKIT_ZENITH_BASE_PATH) {
|
|
17
|
+
throw new BaseException('ZKIT_ZENITH_BASE_PATH environment variable is not set. Please set it to the base path of your project.')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const wrapper = createWrapper({
|
|
21
|
+
zenithDirectory: process.env.ZKIT_ZENITH_BASE_PATH
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
wrapper
|
|
25
|
+
.addEnv('ZENITH_BASE_PATH', process.env.ZKIT_ZENITH_BASE_PATH)
|
|
26
|
+
.addEnv('ZENITH_CONFIG_FS_PATH', path.join(cwd, 'config'))
|
|
27
|
+
.addEnv('ZENITH_PLUGINS', `${id}.directory=${cwd}`)
|
|
28
|
+
.run()
|
package/bin/zkit.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander'
|
|
4
|
+
import { readdirSync } from 'fs'
|
|
5
|
+
import { resolve, dirname } from 'path'
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from 'url'
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
9
|
+
|
|
10
|
+
const program = new Command()
|
|
11
|
+
|
|
12
|
+
program
|
|
13
|
+
.name('zkit')
|
|
14
|
+
.description('CLI tool for zenith-kit')
|
|
15
|
+
|
|
16
|
+
const commandsDir = resolve(__dirname, '..', 'cli', 'commands')
|
|
17
|
+
|
|
18
|
+
for (const file of readdirSync(commandsDir)) {
|
|
19
|
+
if (!file.endsWith('.js')) continue
|
|
20
|
+
|
|
21
|
+
const mod = await import(pathToFileURL(resolve(commandsDir, file)).href)
|
|
22
|
+
|
|
23
|
+
program.addCommand(mod.default)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
program.parse(process.argv)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import * as tsdown from 'tsdown'
|
|
3
|
+
import * as vite from 'vite'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import createTsdownConfig from '../../tsdown/createTsdownConfig.js'
|
|
6
|
+
import createViteConfig from '../../vite/createViteConfig.js'
|
|
7
|
+
import config from '../config.js'
|
|
8
|
+
|
|
9
|
+
const command = new Command('build')
|
|
10
|
+
|
|
11
|
+
command
|
|
12
|
+
.description('Build plugin for production')
|
|
13
|
+
.action(async () => {
|
|
14
|
+
const cwd = process.cwd()
|
|
15
|
+
|
|
16
|
+
const entry = {
|
|
17
|
+
index: 'src/server/index.ts',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (config?.build?.server?.entries) {
|
|
21
|
+
Object.assign(entry, config.build.server.entries)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const tsdownConfig = createTsdownConfig({
|
|
25
|
+
root: cwd,
|
|
26
|
+
entry: entry,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
await tsdown.build(tsdownConfig)
|
|
30
|
+
|
|
31
|
+
const viteNodeConfig = createViteConfig({
|
|
32
|
+
entry: path.resolve(cwd, 'src/client/index.ts'),
|
|
33
|
+
outDir: path.resolve(cwd, 'dist/client-node'),
|
|
34
|
+
ssr: true
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
await vite.build(viteNodeConfig)
|
|
38
|
+
|
|
39
|
+
const viteBrowserConfig = createViteConfig({
|
|
40
|
+
entry: path.resolve(cwd, 'src/client/index.ts'),
|
|
41
|
+
outDir: path.resolve(cwd, 'dist/client-browser'),
|
|
42
|
+
ssr: false
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
await vite.build(viteBrowserConfig)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
export default command
|
|
49
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import createWrapper from '../utils/createWrapper.js'
|
|
3
|
+
import { EnvService } from '../../dist/server/index.mjs'
|
|
4
|
+
import { BaseException } from '../../dist/shared/index.mjs'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
import { kitConfig } from '../config.js'
|
|
7
|
+
|
|
8
|
+
const command = new Command('dev')
|
|
9
|
+
|
|
10
|
+
command
|
|
11
|
+
.description('Start development server with watch mode')
|
|
12
|
+
.action(async () => {
|
|
13
|
+
const cwd = process.cwd()
|
|
14
|
+
const id = kitConfig.module_id
|
|
15
|
+
|
|
16
|
+
EnvService.dotEnvConfig({
|
|
17
|
+
path: path.join(cwd, '.env'),
|
|
18
|
+
quiet: true
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
if (!process.env.ZKIT_ZENITH_BASE_PATH) {
|
|
22
|
+
throw new BaseException('ZKIT_ZENITH_BASE_PATH environment variable is not set. Please set it to the base path of your project.')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const wrapper = createWrapper({
|
|
26
|
+
zenithDirectory: process.env.ZKIT_ZENITH_BASE_PATH
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
wrapper
|
|
30
|
+
.addEnv('ZENITH_BASE_PATH', process.env.ZKIT_ZENITH_BASE_PATH)
|
|
31
|
+
.addEnv('ZENITH_CONFIG_FS_PATH', path.join(cwd, 'config'))
|
|
32
|
+
.addEnv('ZENITH_PLUGINS', `${id}.directory=${cwd}`)
|
|
33
|
+
.run(['serve'])
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export default command
|
|
37
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import createWrapper from '../utils/createWrapper.js'
|
|
3
|
+
import { EnvService } from '../../dist/server/index.mjs'
|
|
4
|
+
import { BaseException } from '../../dist/shared/index.mjs'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
import { kitConfig } from '../config.js'
|
|
7
|
+
|
|
8
|
+
const command = new Command('start')
|
|
9
|
+
|
|
10
|
+
command
|
|
11
|
+
.description('Start product server')
|
|
12
|
+
.action(async () => {
|
|
13
|
+
const cwd = process.cwd()
|
|
14
|
+
const id = kitConfig.module_id
|
|
15
|
+
|
|
16
|
+
EnvService.dotEnvConfig({
|
|
17
|
+
path: path.join(cwd, '.env'),
|
|
18
|
+
quiet: true
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
if (!process.env.ZKIT_ZENITH_BASE_PATH) {
|
|
22
|
+
throw new BaseException('ZKIT_ZENITH_BASE_PATH environment variable is not set. Please set it to the base path of your project.')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const wrapper = createWrapper({
|
|
26
|
+
zenithDirectory: process.env.ZKIT_ZENITH_BASE_PATH
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
wrapper
|
|
30
|
+
.addEnv('ZENITH_BASE_PATH', process.env.ZKIT_ZENITH_BASE_PATH)
|
|
31
|
+
.addEnv('ZENITH_CONFIG_FS_PATH', path.join(cwd, 'config'))
|
|
32
|
+
.addEnv('ZENITH_PLUGINS', `${id}.directory=${cwd}`)
|
|
33
|
+
.run(['serve'])
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
export default command
|
|
37
|
+
|
|
38
|
+
|
package/cli/config.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import cosmicconfig from 'cosmiconfig'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
|
|
4
|
+
const explorer = cosmicconfig.cosmiconfigSync('zenith', {
|
|
5
|
+
searchPlaces: [
|
|
6
|
+
'zenith.config.js',
|
|
7
|
+
'zenith.config.yml',
|
|
8
|
+
'zenith.config.yaml',
|
|
9
|
+
]
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const result = explorer.search()
|
|
14
|
+
|
|
15
|
+
const config = result?.config || {}
|
|
16
|
+
|
|
17
|
+
export const kitConfig = {
|
|
18
|
+
...config?.kit,
|
|
19
|
+
module_id: result?.config?.kit?.module_id || path.basename(process.cwd()),
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default config
|
|
23
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ArtisanWrapperService } from '../../dist/server/index.mjs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
/** @typedef CreateWrapperOptions
|
|
5
|
+
* @property {string} [zenithDirectory] - The base path of the project. If not provided, it will be read from the ZENITH_BASE_PATH environment variable.
|
|
6
|
+
* @property {string} [cwd] - The base path of the project. If not provided, it will be read from the ZENITH_BASE_PATH environment variable.
|
|
7
|
+
* */
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates and runs the ArtisanWrapperService with the provided options.
|
|
11
|
+
* @param {CreateWrapperOptions} options - The options for creating the wrapper.
|
|
12
|
+
*/
|
|
13
|
+
export default function ncreateWrapper(options) {
|
|
14
|
+
return ArtisanWrapperService
|
|
15
|
+
.create()
|
|
16
|
+
.setBasePath(options.zenithDirectory)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|