Skip to content

Commit

Permalink
feat(cli): add artisan-init support
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Sep 22, 2022
1 parent d48b453 commit 995a5f4
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: pnpm artisan build --npm

- name: Publish to npm
run: pnpm --filter './' --filter './.stacks' --filter './.stacks/components' --filter './.stacks/functions' --filter './.stacks/elements' publish --access public --no-git-checks
run: pnpm --filter './' --filter './.stacks' --filter './.stacks/artisan-init' --filter './.stacks/components' --filter './.stacks/functions' --filter './.stacks/elements' publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

Expand Down
12 changes: 12 additions & 0 deletions .stacks/artisan-init/build.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: [
'src/cli',
],
declaration: true,
clean: true,
rollup: {
inlineDependencies: true,
},
})
2 changes: 2 additions & 0 deletions .stacks/artisan-init/cli.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
import './dist/cli.mjs'
46 changes: 46 additions & 0 deletions .stacks/artisan-init/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "artisan-init",
"version": "0.31.18",
"description": "Artisan framework init.",
"author": "Chris Breuer",
"license": "MIT",
"homepage": "https://github.com/ow3org/stacks/tree/main/.stacks/artisan-init#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/ow3org/stacks.git",
"directory": ".stacks/artisan-init"
},
"bugs": {
"url": "https://github.com/ow3org/stacks/issues"
},
"keywords": [
"artisan",
"init",
"cli",
"starter-kit",
"stacks",
"typescript"
],
"sideEffects": false,
"contributors": [
"Chris Breuer <chris@ow3.org>"
],
"files": [
"dist",
"*.mjs"
],
"scripts": {
"artisan-init": "pnpm run dev && node cli.mjs",
"build": "unbuild",
"dev": "unbuild --stub",
"prepublishOnly": "pnpm run build",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"cac": "^6.7.14",
"kolorist": "^1.6.0"
},
"devDependencies": {
"unbuild": "^0.8.11"
}
}
43 changes: 43 additions & 0 deletions .stacks/artisan-init/src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node
import { bold, cyan, dim, red, yellow } from 'kolorist'
import cac from 'cac'
import { version } from '../package.json'

const cli = cac('artisan-init')

cli
.version(version)
.option('--name <name>', 'Name of the stack')
.help()

cli
.command('')
.action(async (args: any) => {
const path = args

// eslint-disable-next-line no-console
console.log('path is', path)

try {
// eslint-disable-next-line no-console
console.log()
// eslint-disable-next-line no-console
console.log(cyan(bold('Artisan CLI')) + dim(` v${version}`))
// eslint-disable-next-line no-console
console.log()

if (args.name) {
// eslint-disable-next-line no-console
console.log(yellow('Name option is set.'))
return
}
}
catch (e: any) {
console.error(red(String(e)))
if (e?.stack)
console.error(dim(e.stack?.split('\n').slice(1).join('\n')))
process.exit(1)
}
})

cli.parse()
4 changes: 2 additions & 2 deletions .stacks/elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
"import": "./dist/index.mjs"
}
},
"main": "dist/index.cjs",
"module": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@
"safelist",
"unimport",
"globalFroms",
"npmrc"
"npmrc",
"kolorist"
],
"html.customData": [
"./.stacks/custom-elements.json"
Expand Down
Loading

0 comments on commit 995a5f4

Please sign in to comment.