Skip to content

Commit

Permalink
init: 初始化项目
Browse files Browse the repository at this point in the history
  • Loading branch information
xuasir committed Jan 27, 2021
1 parent 65d707a commit f7a678d
Show file tree
Hide file tree
Showing 28 changed files with 6,176 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
env: {
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 6,
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-non-null-assertion": 0,
},
};
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
printWidth: 80,
useTabs: false,
tabWidth: 2,
semi: false,
singleQuote: true,
trailingComma: 'none'
}
13 changes: 13 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"packages": [
"packages/*"
],
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
"publish": {
"allowBranch": ["master"]
}
}
}
37 changes: 37 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"private": true,
"workspaces": [
"packages/*"
],
"description": "a bundle tools for js ts react vue based on rollup",
"repository": {
"type": "git",
"url": "git+https://github.com/xus-code/bundle-tools.git"
},
"keywords": [
"bundle",
"esm",
"cjs",
"global",
"typescript",
"js",
"react",
"vue"
],
"author": "guo.xu xuguo@outlook.it",
"license": "MIT",
"bugs": {
"url": "https://github.com/xus-code/bundle-tools/issues"
},
"homepage": "https://github.com/xus-code/bundle-tools#readme",
"devDependencies": {
"@types/node": "^14.14.22",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
"eslint": "^7.18.0",
"eslint-config-prettier": "^7.2.0",
"lerna": "^3.22.1",
"prettier": "^2.2.1",
"typescript": "^4.1.3"
}
}
11 changes: 11 additions & 0 deletions packages/cli-plugin-rollup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `cli`

> TODO: description
## Usage

```
const cli = require('cli');
// TODO: DEMONSTRATE API
```
26 changes: 26 additions & 0 deletions packages/cli-plugin-rollup/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@xus/cli-plugin-rollup",
"version": "0.0.1",
"description": "xus cli plugin rollup",
"keywords": [
"cli",
"rollup"
],
"author": "guo.xu <xuguo@outlook.it>",
"homepage": "https://github.com/xus-code/bundle-tools/tree/master/packages/cli#readme",
"license": "MIT",
"files": [
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/xus-code/bundle-tools.git"
},
"scripts": {
"dev:rollup": "tsc --watch",
"build:rollup": "tsc"
},
"bugs": {
"url": "https://github.com/xus-code/bundle-tools/issues"
}
}
Empty file.
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions packages/cli-plugin-rollup/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"outDir": "./lib",
},
"extends": "../../tsconfig.json",
"include": ["./src/**/*"]
}
11 changes: 11 additions & 0 deletions packages/cli-shared-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `cli`

> TODO: description
## Usage

```
const cli = require('cli');
// TODO: DEMONSTRATE API
```
25 changes: 25 additions & 0 deletions packages/cli-shared-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@xus/cli-shared-utils",
"version": "0.0.1",
"description": "xus cli-shared-utils",
"keywords": [
"cli-shared-utils"
],
"author": "guo.xu <xuguo@outlook.it>",
"homepage": "https://github.com/xus-code/bundle-tools/tree/master/packages/cli#readme",
"license": "MIT",
"files": [
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/xus-code/bundle-tools.git"
},
"scripts": {
"dev:utils": "tsc --watch",
"build:utils": "tsc"
},
"bugs": {
"url": "https://github.com/xus-code/bundle-tools/issues"
}
}
Empty file.
7 changes: 7 additions & 0 deletions packages/cli-shared-utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"outDir": "./lib",
},
"extends": "../../tsconfig.json",
"include": ["./src/**/*"]
}
11 changes: 11 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `cli`

> TODO: description
## Usage

```
const cli = require('cli');
// TODO: DEMONSTRATE API
```
8 changes: 8 additions & 0 deletions packages/cli/lib/Cli.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare class Cli {
ctxPath: string;
constructor(ctxPath: string);
run(commandName: string, args: {
[key: string]: any;
}, rawArgs: any[]): Promise<any>;
}
export default Cli;
17 changes: 17 additions & 0 deletions packages/cli/lib/Cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Cli {
constructor(ctxPath) {
this.ctxPath = process.cwd();
this.ctxPath = ctxPath;
}
async run(commandName, args, rawArgs) {
console.log(`command `, commandName);
console.log(`args `, args);
console.log(`rawArgs `, rawArgs);
// 1. valid commandName (help)
// 2. init cli (load plugin / config...)
// 3. get compiler task run
}
}
exports.default = Cli;
6 changes: 6 additions & 0 deletions packages/cli/lib/PluginAPI.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare class PluginAPI {
id: string;
service: any;
constructor(id: string, service: any);
}
export default PluginAPI;
9 changes: 9 additions & 0 deletions packages/cli/lib/PluginAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class PluginAPI {
constructor(id, service) {
this.id = id;
this.service = service;
}
}
exports.default = PluginAPI;
2 changes: 2 additions & 0 deletions packages/cli/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};
20 changes: 20 additions & 0 deletions packages/cli/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const minimist_1 = __importDefault(require("minimist"));
const Cli_1 = __importDefault(require("./Cli"));
// collect builtIn plugins
// const plugins = []
// 1. init cli
const cli = new Cli_1.default(process.env.XUS_BUNDLE_CONTEXT || process.cwd());
// 2. get args
const rawArgs = process.argv.slice(2);
const args = minimist_1.default(rawArgs);
const commandName = args._[0];
// 3. run commander
cli.run(commandName, args, rawArgs).catch(() => {
process.exit(1);
});
33 changes: 33 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@xus/cli",
"version": "0.0.1",
"description": "xus cli",
"keywords": [
"cli",
"bundle"
],
"author": "guo.xu <xuguo@outlook.it>",
"homepage": "https://github.com/xus-code/bundle-tools/tree/master/packages/cli#readme",
"license": "MIT",
"bin": {
"xus-cli": "./lib/index.js"
},
"files": [
"lib"
],
"repository": {
"type": "git",
"url": "git+https://github.com/xus-code/bundle-tools.git"
},
"scripts": {
"dev:cli": "tsc --watch",
"build:cli": "tsc"
},
"bugs": {
"url": "https://github.com/xus-code/bundle-tools/issues"
},
"dependencies": {
"@types/minimist": "^1.2.1",
"minimist": "^1.2.5"
}
}
20 changes: 20 additions & 0 deletions packages/cli/src/Cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class Cli {
ctxPath: string = process.cwd()
constructor(ctxPath: string) {
this.ctxPath = ctxPath
}
async run(
commandName: string,
args: { [key: string]: any },
rawArgs: any[]
): Promise<any> {
console.log(`command `, commandName)
console.log(`args `, args)
console.log(`rawArgs `, rawArgs)
// 1. valid commandName (help)
// 2. init cli (load plugin / config...)
// 3. get compiler task run
}
}

export default Cli
7 changes: 7 additions & 0 deletions packages/cli/src/PluginAPI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class PluginAPI {
constructor(public id: string, public service: any) {}

// registerCommander(name: string, opt, fn) {}
}

export default PluginAPI
15 changes: 15 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env node
import minimist from 'minimist'
import Cli from './Cli'
// collect builtIn plugins
// const plugins = []
// 1. init cli
const cli = new Cli(process.env.XUS_BUNDLE_CONTEXT || process.cwd())
// 2. get args
const rawArgs = process.argv.slice(2)
const args = minimist(rawArgs)
const commandName = args._[0]
// 3. run commander
cli.run(commandName, args, rawArgs).catch(() => {
process.exit(1)
})
7 changes: 7 additions & 0 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"outDir": "./lib",
},
"extends": "../../tsconfig.json",
"include": ["./src/**/*"]
}
12 changes: 12 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES2017",
"module": "commonjs",
"strict": true,
"declaration": true,
"skipLibCheck": true,
"esModuleInterop": true,
"lib": ["esnext", "dom"]
},
"exclude": ["**/__test__/**/*"]
}
Loading

0 comments on commit f7a678d

Please sign in to comment.