-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
251 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ build/ | |
*.pem | ||
|
||
# debug | ||
tmp/ | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env node | ||
import { spawnSync } from "node:child_process" | ||
import { fileURLToPath } from 'node:url' | ||
import { dirname, resolve } from "node:path" | ||
|
||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = dirname(__filename) | ||
|
||
// find argument string | ||
const index = process.argv.findIndex((arg) => arg === __filename) | ||
const args = process.argv.slice(index + 1) | ||
|
||
// Say our original entrance script is `app.js` | ||
const cmd = `node --no-warnings ${resolve(__dirname, "../build/src/cli.js")}` | ||
spawnSync(cmd, args, { stdio: "inherit", shell: true }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Command } from 'commander' | ||
|
||
import packageJson from '../package.json' assert { "type": "json" } | ||
import { command as init } from './cli/init.js' | ||
import { command as build } from './cli/build.js' | ||
|
||
const { version } = packageJson | ||
|
||
const cli = new Command() | ||
|
||
cli | ||
.version(version) | ||
.addCommand(init()) | ||
.addCommand(build()) | ||
|
||
cli.parseAsync(process.argv) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Command } from 'commander' | ||
|
||
export const command = () => | ||
new Command('init') | ||
.description('Build a project.') | ||
.option('-f, --folder <folder>', 'folder to run the build in', '.') | ||
.option('-c, --config <config>', 'gemforge config file', 'gemforge.config.js') | ||
.action(async (folder: string) => { | ||
console.log(typeof folder, folder) | ||
throw new Error('test') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { $ } from 'execa' | ||
import chalk from 'chalk' | ||
import path, { dirname } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
|
||
const __filename = fileURLToPath(import.meta.url) | ||
const __dirname = dirname(__filename) | ||
|
||
export const $$ = $({ stdio: 'inherit' }) | ||
|
||
export const getContext = (args: Record<string, any>) => { | ||
const context = { | ||
folder: args.folder, | ||
} | ||
|
||
if (context.folder != '.') { | ||
log(`Using folder ${context.folder}`) | ||
context.folder = path.resolve(process.cwd(), context.folder) | ||
} else { | ||
context.folder = process.cwd() | ||
} | ||
|
||
return context | ||
} | ||
|
||
export const template = (file: string) => { | ||
return path.resolve(__dirname, '../templates', file) | ||
} | ||
|
||
export const log = (message: string) => console.log(chalk.gray(message)) | ||
export const info = (message: string) => console.log(chalk.whiteBright(message)) | ||
export const success = (message: string) => console.log(chalk.greenBright(message)) | ||
export const error = (message: string) => console.log(chalk.redBright(message)) | ||
export const warn = (message: string) => console.log(chalk.yellowBright(message)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Command } from 'commander' | ||
import { $$, getContext, info, template } from './common.js' | ||
|
||
export const command = () => | ||
new Command('init') | ||
.description('Initialize a new project, generating all necessary scaffolding.') | ||
.option('-f, --folder <folder>', 'folder to create the scaffold in', '.') | ||
.action(async (args) => { | ||
const ctx = getContext(args) | ||
|
||
// write config file | ||
info('Writing config file...') | ||
await $$`cp ${template('gemforge.config.js')} ${ctx.folder}/gemforge.config.js` | ||
}) |
Empty file.
Oops, something went wrong.