Skip to content

Commit

Permalink
faet: updat
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Nov 7, 2023
1 parent dc1975c commit e521aaf
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/npm-publish.yml
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}}
3 changes: 3 additions & 0 deletions packages/canyon-cli/bin/canyon
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);
32 changes: 32 additions & 0 deletions packages/canyon-cli/package.json
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"
}
}
68 changes: 68 additions & 0 deletions packages/canyon-cli/src/index.ts
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) {}
};
19 changes: 19 additions & 0 deletions packages/canyon-cli/src/tsconfig.json
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": "../"
}
]
}
16 changes: 16 additions & 0 deletions packages/canyon-cli/tsconfig.json
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"]
}
19 changes: 19 additions & 0 deletions packages/canyon-cli/tsup.config.ts
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,
});

0 comments on commit e521aaf

Please sign in to comment.