gardenjs 1.6.2 → 1.6.3

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.
@@ -7,40 +7,22 @@ import { exec } from 'node:child_process'
7
7
  import fs from 'node:fs'
8
8
  import { promisify } from 'node:util'
9
9
  import path, { dirname } from 'path'
10
+ import { createServer, createTsServer } from '../src/server.js'
10
11
  import { fileURLToPath } from 'url'
11
- import { createServer } from '../src/server.js'
12
+
12
13
  const __filename = fileURLToPath(import.meta.url)
13
14
  const __dirname = dirname(__filename)
14
15
  const exampleSourceFolder = path.resolve(__dirname, '../examples') + '/'
15
16
  const execAsync = promisify(exec)
16
17
 
17
18
  if (fs.existsSync('./garden.config.js')) {
18
- createNodeViteServer()
19
+ await createServer()
19
20
  } else if (fs.existsSync('./garden.config.ts')) {
20
- try {
21
- const tsNode = await import('ts-node')
22
- tsNode.register({
23
- transpileOnly: true,
24
- compilerOptions: {
25
- module: 'ESNext',
26
- },
27
- })
28
- createNodeViteServer()
29
- } catch (e) {
30
- throw new Error(
31
- `For typescript support you need to install ts-node and typescript\n\n` +
32
- `npm install --save-dev ts-node typescript\n\n` +
33
- `Original error: ${e.message}`
34
- )
35
- }
21
+ await createTsServer()
36
22
  } else {
37
23
  runSetupScript()
38
24
  }
39
25
 
40
- async function createNodeViteServer() {
41
- await createServer()
42
- }
43
-
44
26
  async function runSetupScript() {
45
27
  console.clear()
46
28
  console.log('Welcome to the garden setup process')
@@ -48,13 +30,29 @@ async function runSetupScript() {
48
30
  separator()
49
31
  console.log('')
50
32
 
51
- const filetype = await select({
52
- message: 'Do you want to use typescript or javascript',
53
- choices: [
54
- { name: 'javascript', value: 'javascript', checked: true },
55
- { name: 'typescript', value: 'typescript' },
56
- ],
57
- })
33
+ const isTypescriptProject =
34
+ fs.existsSync('./tsconfig.json') || fs.existsSync('vite.config.ts')
35
+ const filetype = isTypescriptProject
36
+ ? await select({
37
+ message: 'Do you want to use TypeScript or JavaScript',
38
+ choices: [
39
+ { name: 'TypeScript', value: 'typescript' },
40
+ {
41
+ name: 'JavaScript',
42
+ value: 'javascript',
43
+ },
44
+ ],
45
+ })
46
+ : await select({
47
+ message: 'Do you want to use JavaScript or TypeScript',
48
+ choices: [
49
+ {
50
+ name: 'JavaScript',
51
+ value: 'javascript',
52
+ },
53
+ { name: 'TypeScript', value: 'typescript' },
54
+ ],
55
+ })
58
56
  const gardenFile =
59
57
  filetype === 'javascript' ? 'garden.config.js' : 'garden.config.ts'
60
58
  const gardenViteFile =
@@ -171,7 +169,8 @@ async function runSetupScript() {
171
169
  })
172
170
 
173
171
  console.log('')
174
- console.log('Done. Edit garden.config.js file according to your needs.')
172
+ console.log(`Done. Edit ${gardenFile} file according to your needs.`)
173
+ console.log('')
175
174
  console.log('Run npm run garden again, to start gardenjs.')
176
175
  separator()
177
176
  console.log('Happy gardening!')
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "gardenjs",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "A component library explorer for UI development, testing and documentation.",
5
- "repository": "https://github.com/gardenjs/gardenjs",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/gardenjs/gardenjs.git"
8
+ },
6
9
  "homepage": "https://gardenjs.org/",
7
10
  "main": "index.js",
8
11
  "type": "module",
@@ -64,15 +67,15 @@
64
67
  "prettier-plugin-svelte": "3.4.0",
65
68
  "sass": "1.89.2",
66
69
  "svelte": "5.36.7",
67
- "ts-node": "^10.9.2",
68
- "typescript": "5.8.3",
69
70
  "vite": "7.0.5"
70
71
  },
71
72
  "dependencies": {
72
73
  "@inquirer/checkbox": "1.5.0",
73
74
  "@inquirer/prompts": "3.3.0",
74
75
  "@inquirer/select": "^2.0.0",
76
+ "build": "^0.1.4",
75
77
  "chokidar": "^5.0.0",
78
+ "execa": "^9.6.1",
76
79
  "highlight.js": "11.11.1",
77
80
  "marked": "4.3.0",
78
81
  "node-watch": "0.7.4",
@@ -80,11 +83,11 @@
80
83
  "vite-node": "3.2.4"
81
84
  },
82
85
  "peerDependencies": {
83
- "ts-node": "^10.0.0",
84
- "typescript": "^5.0.0"
86
+ "typescript": "^5.0.0",
87
+ "tsx": "^4.21.0"
85
88
  },
86
89
  "peerDependenciesMeta": {
87
- "ts-node": {
90
+ "tsx": {
88
91
  "optional": true
89
92
  },
90
93
  "typescript": {
@@ -0,0 +1,3 @@
1
+ import { createServer } from './server.js'
2
+
3
+ await createServer()
package/src/server.js CHANGED
@@ -1,12 +1,32 @@
1
1
  import { getConfig } from './config.js'
2
2
  import { fileURLToPath } from 'url'
3
- const __filename = fileURLToPath(import.meta.url)
4
3
  import { dirname } from 'path'
5
- import path from 'path'
6
- const __dirname = dirname(__filename)
7
-
4
+ import path, { join } from 'path'
8
5
  import open from 'open'
6
+ import { execa } from 'execa'
9
7
  import { createServer as createViteServer } from 'vite'
8
+ const __filename = fileURLToPath(import.meta.url)
9
+ const __dirname = dirname(__filename)
10
+
11
+ export async function createTsServer() {
12
+ const { tsconfig } = await getConfig()
13
+ try {
14
+ const tsconfigPath = join(process.cwd(), tsconfig ?? 'tsconfig.json')
15
+ await execa(
16
+ 'tsx',
17
+ ['--tsconfig', tsconfigPath, path.resolve(__dirname, './runTsServer.js')],
18
+ {
19
+ stdio: 'inherit',
20
+ }
21
+ )
22
+ } catch (e) {
23
+ throw new Error(
24
+ `For typescript support you need to install tsx and typescript\n\n` +
25
+ `npm install --save-dev tsx typescript\n\n` +
26
+ `Original error: ${e.message}`
27
+ )
28
+ }
29
+ }
10
30
 
11
31
  export async function createServer() {
12
32
  const { serverport, vite_config, devmodus, no_open_browser } =