-
Notifications
You must be signed in to change notification settings - Fork 45
Feature: Basic CLI #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
35e5591
feat(cli): init cli package and add init command
oscar60310 4aee476
feat(cli, core): write some initial files for demo
oscar60310 c4f96dc
fix(build): unite options injection
oscar60310 7b5b547
feat(cli): implement start command
oscar60310 a56dec7
feat(cli): implement version command
oscar60310 76e75f4
feat(cli): implement build,serve commands
oscar60310 bb3e43d
build: update nx config and package.json for every package
oscar60310 703d4f1
feat(cli): add command descriptions
oscar60310 d625fb8
feat(cli): catching sigint signal and close server before exit
oscar60310 87f5dbf
build: release 0.1.0-alpha.1 for dev usage
oscar60310 ad667a4
test(cli): add test cases for basic commands
oscar60310 b045fe1
fix(cli): fix glob search pattern on Windows
oscar60310 2f75878
build(npm): fix dependencies issues
oscar60310 49ad739
test(cli): add test for version commands
oscar60310 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,27 @@ | ||
| { | ||
| "name": "@vulcan-sql/build", | ||
| "version": "0.0.1", | ||
| "type": "commonjs" | ||
| "description": "Vulcan package for building projects", | ||
| "version": "0.1.0-alpha.1", | ||
| "type": "commonjs", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "keywords": [ | ||
| "vulcan", | ||
| "vulcan-sql", | ||
| "data", | ||
| "sql", | ||
| "database", | ||
| "data-warehouse", | ||
| "data-lake", | ||
| "api-builder" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/Canner/vulcan.git" | ||
| }, | ||
| "license": "MIT", | ||
| "peerDependencies": { | ||
| "@vulcan-sql/core": "0.1.0-alpha.1" | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,18 @@ | ||
| { | ||
| "extends": ["../../.eslintrc.json"], | ||
| "ignorePatterns": ["!**/*"], | ||
| "overrides": [ | ||
| { | ||
| "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
| "rules": {} | ||
| }, | ||
| { | ||
| "files": ["*.ts", "*.tsx"], | ||
| "rules": {} | ||
| }, | ||
| { | ||
| "files": ["*.js", "*.jsx"], | ||
| "rules": {} | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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,12 @@ | ||
| # cli | ||
|
|
||
| This library was generated with [Nx](https://nx.dev). | ||
|
|
||
| ## Building | ||
|
|
||
| Run `nx build cli` to build the library. | ||
|
|
||
| ## Running unit tests | ||
|
|
||
| Run `nx test cli` to execute the unit tests via [Jest](https://jestjs.io). | ||
|
|
This file contains hidden or 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 @@ | ||
| module.exports = { | ||
| displayName: 'cli', | ||
| preset: '../../jest.preset.ts', | ||
| globals: { | ||
| 'ts-jest': { | ||
| tsconfig: '<rootDir>/tsconfig.spec.json', | ||
| }, | ||
| }, | ||
| transform: { | ||
| '^.+\\.[tj]s$': 'ts-jest', | ||
| }, | ||
| moduleFileExtensions: ['ts', 'js', 'html'], | ||
| coverageDirectory: '../../coverage/packages/cli', | ||
| }; |
This file contains hidden or 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,27 @@ | ||
| { | ||
| "name": "@vulcan-sql/cli", | ||
| "description": "CLI tools for Vulcan", | ||
| "version": "0.1.0-alpha.1", | ||
| "type": "commonjs", | ||
| "bin": { | ||
| "vulcan": "./src/index.js" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "keywords": [ | ||
| "vulcan", | ||
| "vulcan-sql", | ||
| "data", | ||
| "sql", | ||
| "database", | ||
| "data-warehouse", | ||
| "data-lake", | ||
| "api-builder" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/Canner/vulcan.git" | ||
| }, | ||
| "license": "MIT" | ||
| } |
This file contains hidden or 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,91 @@ | ||
| { | ||
| "root": "packages/cli", | ||
| "sourceRoot": "packages/cli/src", | ||
| "targets": { | ||
| "build": { | ||
| "executor": "@nrwl/workspace:run-commands", | ||
| "options": { | ||
| "commands": [ | ||
| { | ||
| "command": "yarn ts-node ./tools/scripts/replaceAlias.ts cli", | ||
| "forwardAllArgs": false | ||
| }, | ||
| { | ||
| "command": "chmod +x dist/packages/cli/src/index.js", | ||
| "forwardAllArgs": false | ||
| } | ||
| ] | ||
| }, | ||
| "dependsOn": [ | ||
| { | ||
| "projects": "self", | ||
| "target": "tsc" | ||
| } | ||
| ] | ||
| }, | ||
| "tsc": { | ||
| "executor": "@nrwl/js:tsc", | ||
| "outputs": ["{options.outputPath}"], | ||
| "options": { | ||
| "outputPath": "dist/packages/cli", | ||
| "main": "packages/cli/src/index.ts", | ||
| "tsConfig": "packages/cli/tsconfig.lib.json", | ||
| "assets": ["packages/cli/*.md", "packages/cli/src/schemas/**/*.*"], | ||
| "buildableProjectDepsInPackageJsonType": "dependencies" | ||
| }, | ||
| "dependsOn": [ | ||
| { | ||
| "projects": "dependencies", | ||
| "target": "build" | ||
| } | ||
| ] | ||
| }, | ||
| "publish": { | ||
| "executor": "@nrwl/workspace:run-commands", | ||
| "options": { | ||
| "command": "node ../../../tools/scripts/publish.mjs {args.tag}", | ||
| "cwd": "dist/packages/cli" | ||
| }, | ||
| "dependsOn": [ | ||
| { | ||
| "projects": "self", | ||
| "target": "build" | ||
| } | ||
| ] | ||
| }, | ||
| "lint": { | ||
| "executor": "@nrwl/linter:eslint", | ||
| "outputs": ["{options.outputFile}"], | ||
| "options": { | ||
| "lintFilePatterns": ["packages/cli/**/*.ts"] | ||
| } | ||
| }, | ||
| "test": { | ||
| "executor": "@nrwl/jest:jest", | ||
| "outputs": ["coverage/packages/cli"], | ||
| "options": { | ||
| "jestConfig": "packages/cli/jest.config.ts", | ||
| "passWithNoTests": true | ||
| } | ||
| }, | ||
| "install": { | ||
| "executor": "@nrwl/workspace:run-commands", | ||
| "options": { | ||
| "commands": [ | ||
| { | ||
| "command": "npm i -g . && echo done.", | ||
| "forwardAllArgs": false | ||
| } | ||
| ], | ||
| "cwd": "dist/packages/cli" | ||
| }, | ||
| "dependsOn": [ | ||
| { | ||
| "projects": "self", | ||
| "target": "build" | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| "tags": [] | ||
| } |
This file contains hidden or 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,61 @@ | ||
| import { program } from 'commander'; | ||
| import { handleInit, handleStart, handleVersion } from './commands'; | ||
| import { handleBuild } from './commands/build'; | ||
| import { handleServe } from './commands/serve'; | ||
|
|
||
| program.exitOverride(); | ||
|
|
||
| program | ||
| .command('version') | ||
| .description('show the version of CLI and Vulcan packages') | ||
| .action(async () => { | ||
| await handleVersion(); | ||
| }); | ||
|
|
||
| program | ||
| .command('init') | ||
| .description('create a new Vulcan project') | ||
| .option('-p --project-name <project-name>', 'specify project name') | ||
| .action(async (options) => { | ||
| await handleInit(options); | ||
| }); | ||
|
|
||
| program | ||
| .command('build') | ||
| .description('build Vulcan project') | ||
| .option( | ||
| '-c --config <config-path>', | ||
| 'path to Vulcan config file', | ||
| './vulcan.yaml' | ||
| ) | ||
| .action(async (options) => { | ||
| await handleBuild(options); | ||
| }); | ||
|
|
||
| program | ||
| .command('serve') | ||
| .description('serve Vulcan project') | ||
| .option( | ||
| '-c --config <config-path>', | ||
| 'path to Vulcan config file', | ||
| './vulcan.yaml' | ||
| ) | ||
| .option('-p --port <port>', 'server port', '3000') | ||
| .action(async (options) => { | ||
| await handleServe(options); | ||
| }); | ||
|
|
||
| program | ||
| .command('start') | ||
| .description('build and serve Vulcan project') | ||
| .option( | ||
| '-c --config <config-path>', | ||
| 'path to Vulcan config file', | ||
| './vulcan.yaml' | ||
| ) | ||
| .option('-p --port <port>', 'server port', '3000') | ||
| .action(async (options) => { | ||
| await handleStart(options); | ||
| }); | ||
|
|
||
| export { program }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the property
buildableProjectDepsInPackageJsonTypecould the nx automatically add dependencies and buildable libraries so that we could publish a library with all dependencies ? (nrwl/nx#4620)if it is true, maybe you could add the comment to let others know the purpose so that we could remind it to add when we create new nx packages and would like to publish in the future?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://nx.dev/packages/js/executors/tsc
The property
updateBuildableProjectDepsInPackageJsoncontrol whether to add dependencies to package.json or not, its default value is true.The setting here enforces the generator put these dependencies to "dependencies" but not "peerDependencies",
I'll add some comments to tell the reasonUpdate: We can't add comments in JSON file 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @oscar60310 for answering my question, it was really helpful for me to understand its importance in the project.
That's fine. 😄 Still thanks for sharing the message, if there, I will memo it in my note.