-
Notifications
You must be signed in to change notification settings - Fork 14
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
1 parent
dc1975c
commit e521aaf
Showing
7 changed files
with
188 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Npm Publish | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
install: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
|
||
publish-npm: | ||
needs: [install] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: pnpm install | ||
# - run: pnpm --filter=@arextest/arex-common publish -f --no-git-checks --access=public --filter | ||
- run: pnpm --filter=@canyon/cli publish -f --no-git-checks --access=public --filter | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} |
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,3 @@ | ||
#!/usr/bin/env node | ||
// * The entry point of the CLI | ||
require("../dist").cli(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,32 @@ | ||
{ | ||
"name": "@canyon/cli", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "dist/index.js", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"build": "pnpm exec tsup", | ||
"dev": "pnpm exec tsup --watch", | ||
"debugger": "node debugger.js 9999", | ||
"prepublish": "pnpm exec tsup", | ||
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write", | ||
"do-typecheck": "pnpm exec tsc --noEmit", | ||
"test": "pnpm run build && jest && rm -rf dist" | ||
}, | ||
"bin": { | ||
"canyon": "bin/canyon" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"chalk": "^5.3.0", | ||
"commander": "^11.1.0" | ||
}, | ||
"devDependencies": { | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
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,68 @@ | ||
import chalk from "chalk"; | ||
import { program } from "commander"; | ||
import { version } from "../package.json"; | ||
|
||
const accent = chalk.greenBright; | ||
|
||
async function test(path: any, options: any): Promise<any>{ | ||
console.log(path, options); | ||
return () => {}; | ||
} | ||
|
||
/** | ||
* * Program Default Configuration | ||
*/ | ||
const CLI_BEFORE_ALL_TXT = `canyon: The ${accent( | ||
"Canyon" | ||
)} CLI - Version ${version} (${accent( | ||
"https://github.com/canyon-project/canyon" | ||
)}) ${chalk.black.bold.bgYellowBright(" ALPHA ")} \n`; | ||
|
||
const CLI_AFTER_ALL_TXT = `\nFor more help, head on to ${accent( | ||
"https://github.com/canyon-project/canyon" | ||
)}`; | ||
|
||
program | ||
.name("canyon") | ||
.version(version, "-v, --version", "see the current version of canyon-cli") | ||
.usage("[options or commands] arguments") | ||
.addHelpText("beforeAll", CLI_BEFORE_ALL_TXT) | ||
.addHelpText("after", CLI_AFTER_ALL_TXT) | ||
.configureHelp({ | ||
optionTerm: (option) => accent(option.flags), | ||
subcommandTerm: (cmd) => accent(cmd.name(), cmd.usage()), | ||
argumentTerm: (arg) => accent(arg.name()), | ||
}) | ||
.addHelpCommand(false) | ||
.showHelpAfterError(true); | ||
|
||
|
||
/** | ||
* * CLI Commands | ||
*/ | ||
program | ||
.command("report") | ||
.argument( | ||
"<file_path>", | ||
"path to a istanbul coverage.json file" | ||
) | ||
.option("-s, --sha <commit_sha>", "commit sha of the project") | ||
.option( | ||
"-i, --id <project_id>", | ||
"id of the project" | ||
) | ||
.allowExcessArguments(false) | ||
.allowUnknownOption(false) | ||
.description("report istanbul coverage.json file") | ||
.addHelpText( | ||
"after", | ||
`\nFor help, head on to ${accent( | ||
"https://github.com/canyon-project/canyon" | ||
)}` | ||
) | ||
.action(async (path, options) => await test(path, options)); | ||
export const cli = async (args: string[]) => { | ||
try { | ||
await program.parseAsync(args); | ||
} catch (e) {} | ||
}; |
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,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES6", | ||
"module": "commonjs", | ||
"outDir": "../dist", | ||
"rootDir": ".", | ||
"strict": true, | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"references": [ | ||
{ | ||
"path": "../" | ||
} | ||
] | ||
} |
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,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES6", | ||
"module": "commonjs", | ||
"outDir": ".", | ||
"rootDir": ".", | ||
"strict": true, | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"composite": true | ||
}, | ||
"files": ["package.json"] | ||
} |
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,19 @@ | ||
import { defineConfig } from "tsup"; | ||
|
||
export default defineConfig({ | ||
entry: [ "./src/index.ts" ], | ||
outDir: "./dist/", | ||
format: ["cjs"], | ||
platform: "node", | ||
sourcemap: true, | ||
bundle: true, | ||
target: "node12", | ||
skipNodeModulesBundle: false, | ||
esbuildOptions(options) { | ||
options.bundle = true | ||
}, | ||
noExternal: [ | ||
/\w+/ | ||
], | ||
clean: true, | ||
}); |