Skip to content

Commit

Permalink
feat(@dpc-sdp/nuxt-ripple-cli): ✨ default rplVersion to latest from pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
dylankelly committed Jul 18, 2023
1 parent d647738 commit b7a5992
Show file tree
Hide file tree
Showing 6 changed files with 641 additions and 212 deletions.
1 change: 1 addition & 0 deletions packages/nuxt-ripple-cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/version.ts
3 changes: 3 additions & 0 deletions packages/nuxt-ripple-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"main": "./dist/index.js",
"scripts": {
"nuxt-ripple": "node ./dist/commands/index.js",
"preinstall": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
"build": "rimraf ./dist && tsc && npm run cp-templates && chmod +x ./dist/commands/index.js",
"watch": "rimraf ./dist && tsc --watch",
"local": "sudo npm i -g && nuxt-ripple",
Expand All @@ -21,6 +22,8 @@
"enquirer": "^2.3.6",
"hygen": "^6.2.11",
"mockttp": "^3.7.5",
"npm-check-updates": "^16.10.16",
"object-to-argv": "^2.0.0",
"rimraf": "^4.4.1",
"ts-node": "^10.7.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ to: package.json
---
{
"private": true,
"license": "Apache-2.0",
"name": "<%= h.changeCase.kebabCase(name) %>",
"description": "<%= name %>",
"version": "2.0.0",
"version": "0.0.0",
"scripts": {
"dev": "nuxi dev",
"dev:debug": "node --inspect node_modules/.bin/nuxi dev",
Expand All @@ -31,6 +30,6 @@ to: package.json
},
"engines": {
"node": "^16.17.0 || ^18.12.1",
"npm": "^8.1.0"
"npm": "^9.5.1"
}
}
10 changes: 6 additions & 4 deletions packages/nuxt-ripple-cli/src/commands/init/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import commander from 'commander'
import init from './init'
import { LIB_VERSION } from './../../version'

export default function rplInitCommand() {
const rplInitCommand = new commander.Command('init')
Expand All @@ -17,12 +18,13 @@ export default function rplInitCommand() {
process.cwd()
)
.requiredOption('--name [name]', 'The project name: eg: example-vic-gov-au')
.requiredOption(
.option(
'--rplVersion [rplVersion]',
'The ripple version to use: eg: 2.1.0'
`The ripple version to use: eg: 2.1.0, default is most up to date version`,
LIB_VERSION
)
.action((template, directory) => {
init(template, directory)
.action((template, directory, options) => {
init(template, directory, options)
console.info(`
A new Ripple ${template} has been created in ${directory}.
Run the following to get started:
Expand Down
6 changes: 4 additions & 2 deletions packages/nuxt-ripple-cli/src/commands/init/init.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import path from 'node:path'
import { runner, Logger } from 'hygen'
import enquirer from 'enquirer'
export default function init(template = 'site', projectFolder) {
import objectToArgv from 'object-to-argv'

export default function init(template = 'site', projectFolder, options = {}) {
const defaultTemplates = path.join(__dirname, '_templates')
runner([template, 'latest', ...process.argv.slice(5)], {
runner([template, 'latest', ...objectToArgv(options)], {
templates: defaultTemplates,
/* @ts-ignore */
createPrompter: () => enquirer,
Expand Down
Loading

0 comments on commit b7a5992

Please sign in to comment.