Skip to content

Commit 66c83d9

Browse files
committed
fix: bump version to 0.1.9 in package.json and improve installation prompts and scripts
1 parent c5cec0a commit 66c83d9

6 files changed

Lines changed: 69 additions & 14 deletions

File tree

create-arkstack/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "create-arkstack",
33
"type": "module",
4-
"version": "0.1.8",
4+
"version": "0.1.9",
55
"description": "Scaffold new H3.js or Express.js applications using Toneflix's arkstack templates and starter kits",
66
"homepage": "https://arkstack.toneflix.net",
77
"repository": {
@@ -65,7 +65,6 @@
6565
"bin/run.js"
6666
],
6767
"dependencies": {
68-
"tsdown": "^0.15.4",
6968
"@antfu/install-pkg": "1.1.0",
7069
"@h3ravel/collect.js": "^5.3.4",
7170
"@h3ravel/musket": "^0.10.1",
@@ -74,7 +73,9 @@
7473
"@inquirer/core": "^10.2.2",
7574
"giget": "^2.0.0",
7675
"inquirer": "^12.9.6",
77-
"ora": "^9.0.0"
76+
"ora": "^9.0.0",
77+
"tinyexec": "^1.0.2",
78+
"tsdown": "^0.15.4"
7879
},
7980
"devDependencies": {
8081
"@changesets/cli": "^2.29.5",

create-arkstack/src/Commands/CreateArkstackCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class CreateArkstackCommand extends Command {
123123
{
124124
type: 'confirm',
125125
name: 'install',
126-
message: 'Would you want to install node_modules right away:',
126+
message: 'Would you like to install node_modules right away?:',
127127
default: true,
128128
when: () => !options.install,
129129
},

create-arkstack/src/actions.ts

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { Logger, Resolver } from '@h3ravel/shared'
22
import { copyFile, readFile, readdir, rm, unlink, writeFile } from 'node:fs/promises'
33
import { depsToAdd, depsToRemove, filesToRemove } from './data'
4-
import { detectPackageManager, installPackage } from '@antfu/install-pkg'
54
import path, { basename, join, relative } from 'node:path'
65

76
import { Str } from '@h3ravel/support'
87
import { chdir } from 'node:process'
98
import { depsList } from './data'
9+
import { detectPackageManager } from '@antfu/install-pkg'
1010
import { downloadTemplate } from 'giget'
11+
import { exec } from 'tinyexec'
1112
import { existsSync } from 'node:fs'
13+
import { spawnSync } from 'node:child_process'
1214

1315
export default class {
1416
skipInstallation?: boolean
@@ -61,7 +63,6 @@ export default class {
6163
const status = await downloadTemplate(template, {
6264
dir: this.location,
6365
auth,
64-
install,
6566
provider: 'github',
6667
registry: await this.pm(),
6768
forceClean: false,
@@ -70,14 +71,40 @@ export default class {
7071
return status
7172
}
7273

73-
async installPackage (name: string) {
74-
await installPackage(name, {
75-
cwd: this.location,
76-
silent: true,
74+
/**
75+
* Installs the project dependencies using the detected package manager.
76+
* If a specific package name is provided, it will install that package
77+
* instead of all dependencies.
78+
*
79+
* @param name
80+
* @param args
81+
* @returns
82+
*/
83+
async installPackage (name?: string, args: string[] = []) {
84+
const bcmd = await Resolver.getPakageInstallCommand() + (name ? ` ${name}` : '')
85+
const cmd = bcmd.split(' ')[0]
86+
if (bcmd.includes(' ')) {
87+
args.unshift(...bcmd.split(' ').slice(1))
88+
}
89+
90+
const child = spawnSync(cmd, args, {
91+
cwd: process.cwd(),
92+
stdio: 'ignore',
7793
})
94+
95+
if (child.error) {
96+
return child.status
97+
}
98+
99+
return 0
78100
}
79101

80-
async complete (installed = false) {
102+
async complete (install = false) {
103+
let installed = false
104+
if (install) {
105+
installed = await this.installPackage() === 0
106+
}
107+
81108
console.log('')
82109

83110
const installPath = './' + relative(process.cwd(), this.location!)

packages/console-slim/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"access": "public"
3535
},
3636
"bin": {
37-
"ark": "./dist/index.js"
37+
"ark": "./dist/index.js",
38+
"prepare": "./dist/prepare.js"
3839
},
3940
"exports": {
4041
".": {
@@ -56,4 +57,4 @@
5657
"chalk": "^5.6.2",
5758
"resora": "^0.2.6"
5859
}
59-
}
60+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import chalk from 'chalk'
2+
import { spawn } from 'node:child_process'
3+
4+
const command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'
5+
const child = spawn(command, ['exec', 'tsdown', '--log-level=silent'], {
6+
cwd: process.cwd(),
7+
stdio: 'inherit',
8+
env: Object.assign({}, process.env, {
9+
NODE_ENV: 'production',
10+
}),
11+
})
12+
13+
child.on('error', (error) => {
14+
throw error
15+
})
16+
17+
child.on('exit', (code) => {
18+
if (code === 0 || code === null) {
19+
console.log(chalk.green('Arkstak is ready for development!'))
20+
21+
return
22+
}
23+
24+
throw new Error(`tsdown exited with code ${code}`)
25+
26+
})

packages/console-slim/tsdown.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { defineConfig } from 'tsdown'
44
import path from 'node:path'
55

66
export default defineConfig({
7-
entry: ['src/index.ts', 'src/app.ts'],
7+
entry: ['src/index.ts', 'src/app.ts', 'src/prepare.ts'],
88
format: 'esm',
99
sourcemap: true,
1010
dts: true,

0 commit comments

Comments
 (0)