@jujulego/jill 2.0.0-beta.2 → 2.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/commands/each.d.ts +16 -0
- package/dist/commands/each.d.ts.map +1 -0
- package/dist/commands/each.js +117 -0
- package/dist/commands/each.js.map +1 -0
- package/dist/commands/{list.command.d.ts → list.d.ts} +3 -5
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +170 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/run.d.ts +8 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +59 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/tree.d.ts +3 -0
- package/dist/commands/tree.d.ts.map +1 -0
- package/dist/commands/tree.js +35 -0
- package/dist/commands/tree.js.map +1 -0
- package/dist/filters/affected.filter.d.ts +11 -0
- package/dist/filters/affected.filter.d.ts.map +1 -0
- package/dist/filters/affected.filter.js +82 -0
- package/dist/filters/affected.filter.js.map +1 -0
- package/dist/filters/index.d.ts +4 -0
- package/dist/filters/index.d.ts.map +1 -0
- package/dist/filters/index.js +21 -0
- package/dist/filters/index.js.map +1 -0
- package/dist/filters/pipeline.d.ts +11 -0
- package/dist/filters/pipeline.d.ts.map +1 -0
- package/dist/filters/pipeline.js +34 -0
- package/dist/filters/pipeline.js.map +1 -0
- package/dist/filters/private.filter.d.ts +7 -0
- package/dist/filters/private.filter.d.ts.map +1 -0
- package/dist/filters/private.filter.js +20 -0
- package/dist/filters/private.filter.js.map +1 -0
- package/dist/filters/scripts.filter.d.ts +7 -0
- package/dist/filters/scripts.filter.d.ts.map +1 -0
- package/dist/filters/scripts.filter.js +21 -0
- package/dist/filters/scripts.filter.js.map +1 -0
- package/dist/git.d.ts +16 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +94 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -33
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +26 -62
- package/dist/main.js.map +1 -1
- package/dist/middlewares/global-config.d.ts +5 -0
- package/dist/middlewares/global-config.d.ts.map +1 -0
- package/dist/middlewares/global-config.js +29 -0
- package/dist/middlewares/global-config.js.map +1 -0
- package/dist/middlewares/index.d.ts +4 -0
- package/dist/middlewares/index.d.ts.map +1 -0
- package/dist/middlewares/index.js +21 -0
- package/dist/middlewares/index.js.map +1 -0
- package/dist/middlewares/load-project.d.ts +6 -0
- package/dist/middlewares/load-project.d.ts.map +1 -0
- package/dist/middlewares/load-project.js +41 -0
- package/dist/middlewares/load-project.js.map +1 -0
- package/dist/middlewares/load-workspace.d.ts +3 -0
- package/dist/middlewares/load-workspace.d.ts.map +1 -0
- package/dist/middlewares/load-workspace.js +42 -0
- package/dist/middlewares/load-workspace.js.map +1 -0
- package/dist/middlewares/setup-ink.d.ts +1 -0
- package/dist/middlewares/setup-ink.d.ts.map +1 -0
- package/dist/middlewares/setup-ink.js +22 -0
- package/dist/middlewares/setup-ink.js.map +1 -0
- package/dist/project/index.d.ts +2 -0
- package/dist/project/index.d.ts.map +1 -0
- package/dist/project/index.js +19 -0
- package/dist/project/index.js.map +1 -0
- package/dist/project/project.d.ts +25 -0
- package/dist/project/project.d.ts.map +1 -0
- package/dist/project/project.js +190 -0
- package/dist/project/project.js.map +1 -0
- package/dist/project/workspace.d.ts +34 -0
- package/dist/project/workspace.d.ts.map +1 -0
- package/dist/project/workspace.js +173 -0
- package/dist/project/workspace.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +21 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/inversify.config.d.ts +11 -0
- package/dist/services/inversify.config.d.ts.map +1 -0
- package/dist/services/inversify.config.js +34 -0
- package/dist/services/inversify.config.js.map +1 -0
- package/dist/services/logger.service.d.ts +6 -0
- package/dist/services/logger.service.d.ts.map +1 -0
- package/dist/services/logger.service.js +75 -0
- package/dist/services/logger.service.js.map +1 -0
- package/dist/services/spinner.service.d.ts +18 -0
- package/dist/services/spinner.service.d.ts.map +1 -0
- package/dist/services/spinner.service.js +68 -0
- package/dist/services/spinner.service.js.map +1 -0
- package/dist/services/task-manager.service.d.ts +1 -0
- package/dist/services/task-manager.service.d.ts.map +1 -0
- package/dist/services/task-manager.service.js +18 -0
- package/dist/services/task-manager.service.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/global-spinner.d.ts +2 -0
- package/dist/ui/global-spinner.d.ts.map +1 -0
- package/dist/ui/global-spinner.js +65 -0
- package/dist/ui/global-spinner.js.map +1 -0
- package/dist/ui/index.d.ts +7 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +24 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/layout.d.ts +2 -0
- package/dist/ui/layout.d.ts.map +1 -0
- package/dist/ui/layout.js +20 -0
- package/dist/ui/layout.js.map +1 -0
- package/dist/ui/list.d.ts +6 -0
- package/dist/ui/list.d.ts.map +1 -0
- package/dist/ui/list.js +30 -0
- package/dist/ui/list.js.map +1 -0
- package/dist/{components/StaticLogs.d.ts → ui/static-logs.d.ts} +0 -0
- package/dist/ui/static-logs.d.ts.map +1 -0
- package/dist/ui/static-logs.js +63 -0
- package/dist/ui/static-logs.js.map +1 -0
- package/dist/ui/task-name.d.ts +6 -0
- package/dist/ui/task-name.d.ts.map +1 -0
- package/dist/ui/task-name.js +35 -0
- package/dist/ui/task-name.js.map +1 -0
- package/dist/ui/task-spinner.d.ts +6 -0
- package/dist/ui/task-spinner.d.ts.map +1 -0
- package/dist/ui/task-spinner.js +143 -0
- package/dist/ui/task-spinner.js.map +1 -0
- package/dist/ui/tasks-spinner.d.ts +6 -0
- package/dist/ui/tasks-spinner.d.ts.map +1 -0
- package/dist/ui/tasks-spinner.js +17 -0
- package/dist/ui/tasks-spinner.js.map +1 -0
- package/dist/{components/WorkspaceTree.d.ts → ui/workspace-tree.d.ts} +1 -1
- package/dist/ui/workspace-tree.d.ts.map +1 -0
- package/dist/ui/workspace-tree.js +87 -0
- package/dist/ui/workspace-tree.js.map +1 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +72 -0
- package/dist/utils.js.map +1 -0
- package/package.json +55 -56
- package/dist/application.context.d.ts +0 -28
- package/dist/application.context.d.ts.map +0 -1
- package/dist/application.context.js +0 -30
- package/dist/application.context.js.map +0 -1
- package/dist/application.d.ts +0 -7
- package/dist/application.d.ts.map +0 -1
- package/dist/application.js +0 -125
- package/dist/application.js.map +0 -1
- package/dist/command.d.ts +0 -8
- package/dist/command.d.ts.map +0 -1
- package/dist/command.js +0 -24
- package/dist/command.js.map +0 -1
- package/dist/commands/each.command.d.ts +0 -18
- package/dist/commands/each.command.d.ts.map +0 -1
- package/dist/commands/each.command.js +0 -176
- package/dist/commands/each.command.js.map +0 -1
- package/dist/commands/list.command.d.ts.map +0 -1
- package/dist/commands/list.command.js +0 -252
- package/dist/commands/list.command.js.map +0 -1
- package/dist/commands/run.command.d.ts +0 -12
- package/dist/commands/run.command.d.ts.map +0 -1
- package/dist/commands/run.command.js +0 -94
- package/dist/commands/run.command.js.map +0 -1
- package/dist/commands/tree.command.d.ts +0 -7
- package/dist/commands/tree.command.d.ts.map +0 -1
- package/dist/commands/tree.command.js +0 -35
- package/dist/commands/tree.command.js.map +0 -1
- package/dist/components/StaticLogs.d.ts.map +0 -1
- package/dist/components/StaticLogs.js +0 -77
- package/dist/components/StaticLogs.js.map +0 -1
- package/dist/components/WorkspaceTree.d.ts.map +0 -1
- package/dist/components/WorkspaceTree.js +0 -151
- package/dist/components/WorkspaceTree.js.map +0 -1
- package/dist/wrapper.d.ts +0 -6
- package/dist/wrapper.d.ts.map +0 -1
- package/dist/wrapper.js +0 -30
- package/dist/wrapper.js.map +0 -1
- package/dist/wrappers/project.wrapper.d.ts +0 -7
- package/dist/wrappers/project.wrapper.d.ts.map +0 -1
- package/dist/wrappers/project.wrapper.js +0 -105
- package/dist/wrappers/project.wrapper.js.map +0 -1
- package/dist/wrappers/workspace.wrapper.d.ts +0 -5
- package/dist/wrappers/workspace.wrapper.d.ts.map +0 -1
- package/dist/wrappers/workspace.wrapper.js +0 -108
- package/dist/wrappers/workspace.wrapper.js.map +0 -1
package/dist/utils.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
combine: ()=>combine,
|
|
13
|
+
streamLines: ()=>streamLines,
|
|
14
|
+
applyMiddlewares: ()=>applyMiddlewares,
|
|
15
|
+
defineCommand: ()=>defineCommand,
|
|
16
|
+
defineMiddleware: ()=>defineMiddleware,
|
|
17
|
+
capitalize: ()=>capitalize
|
|
18
|
+
});
|
|
19
|
+
const _eventTree = require("@jujulego/event-tree");
|
|
20
|
+
async function* combine(...generators) {
|
|
21
|
+
for (const gen of generators){
|
|
22
|
+
yield* gen;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function* streamLines(task, stream) {
|
|
26
|
+
// Abort
|
|
27
|
+
const ctrl = new AbortController();
|
|
28
|
+
task.subscribe('status.done', ()=>ctrl.abort());
|
|
29
|
+
task.subscribe('status.failed', ()=>ctrl.abort());
|
|
30
|
+
// Stream
|
|
31
|
+
let current = '';
|
|
32
|
+
try {
|
|
33
|
+
for await (const chunk of (0, _eventTree.streamEvents)(task, `stream.${stream}`, {
|
|
34
|
+
signal: ctrl.signal
|
|
35
|
+
})){
|
|
36
|
+
const data = current + chunk.data.toString('utf-8');
|
|
37
|
+
const lines = data.split(/\r?\n/g);
|
|
38
|
+
current = lines.pop() ?? '';
|
|
39
|
+
for (const line of lines){
|
|
40
|
+
yield line;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} catch (err) {
|
|
44
|
+
if (task.exitCode !== 0) {
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
if (current) {
|
|
48
|
+
yield current;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function applyMiddlewares(yargs, middlewares) {
|
|
53
|
+
let tmp = yargs;
|
|
54
|
+
for (const middleware of middlewares){
|
|
55
|
+
if (middleware.builder) {
|
|
56
|
+
tmp = middleware.builder(tmp);
|
|
57
|
+
}
|
|
58
|
+
tmp.middleware(middleware.handler);
|
|
59
|
+
}
|
|
60
|
+
return tmp;
|
|
61
|
+
}
|
|
62
|
+
function defineCommand(command) {
|
|
63
|
+
return command;
|
|
64
|
+
}
|
|
65
|
+
function defineMiddleware(middleware) {
|
|
66
|
+
return middleware;
|
|
67
|
+
}
|
|
68
|
+
function capitalize(txt) {
|
|
69
|
+
return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["utils.js"],"sourcesContent":["import { streamEvents } from '@jujulego/event-tree';\nimport { SpawnTask, SpawnTaskStream } from '@jujulego/tasks';\nimport { Arguments, Argv, CommandModule } from 'yargs';\nimport { Awaitable } from './types';\n\n// Stream utils\nexport async function* combine<T>(...generators: AsyncGenerator<T>[]): AsyncGenerator<T> {\n for (const gen of generators) {\n yield* gen;\n }\n}\n\nexport async function *streamLines(task: SpawnTask, stream: SpawnTaskStream): AsyncGenerator<string> {\n // Abort\n const ctrl = new AbortController();\n\n task.subscribe('status.done', () => ctrl.abort());\n task.subscribe('status.failed', () => ctrl.abort());\n\n // Stream\n let current = '';\n\n try {\n for await (const chunk of streamEvents(task, `stream.${stream}`, { signal: ctrl.signal })) {\n const data = current + chunk.data.toString('utf-8');\n const lines = data.split(/\\r?\\n/g);\n\n current = lines.pop() ?? '';\n\n for (const line of lines) {\n yield line;\n }\n }\n } catch (err) {\n if (task.exitCode !== 0) {\n throw err;\n }\n\n if (current) {\n yield current;\n }\n }\n}\n\n// Command utils\nexport interface Middleware<T = unknown, U = unknown> {\n builder?: (yargs: Argv<T>) => Argv<U>;\n handler(args: Arguments<U>): Awaitable<void>;\n}\n\nexport function applyMiddlewares<T>(yargs: Argv<T>, middlewares: Middleware[]): Argv<T> {\n let tmp: Argv<unknown> = yargs;\n\n for (const middleware of middlewares) {\n if (middleware.builder) {\n tmp = middleware.builder(tmp);\n }\n\n tmp.middleware(middleware.handler);\n }\n\n return tmp as Argv<T>;\n}\n\nexport function defineCommand<T, U>(command: CommandModule<T, U>): CommandModule<T, U> {\n return command;\n}\n\nexport function defineMiddleware<T, U>(middleware: Middleware<T, U>): Middleware<T, U> {\n return middleware;\n}\n\n// String utils\nexport function capitalize(txt: string): string {\n return txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();\n}\n"],"names":["combine","streamLines","applyMiddlewares","defineCommand","defineMiddleware","capitalize","generators","gen","task","stream","ctrl","AbortController","subscribe","abort","current","chunk","streamEvents","signal","data","toString","lines","split","pop","line","err","exitCode","yargs","middlewares","tmp","middleware","builder","handler","command","txt","charAt","toUpperCase","substring","toLowerCase"],"mappings":"AAAA;;;;;;;;;;;IAMuBA,OAAO,MAAPA;IAMAC,WAAW,MAAXA;IAsCPC,gBAAgB,MAAhBA;IAcAC,aAAa,MAAbA;IAIAC,gBAAgB,MAAhBA;IAKAC,UAAU,MAAVA;;2BAzEa;AAMtB,gBAAgBL,QAAW,GAAGM,UAA+B,EAAqB;IACvF,KAAK,MAAMC,OA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nE","file":"utils.js"}
|
package/package.json
CHANGED
|
@@ -1,88 +1,87 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jujulego/jill",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/Jujulego/jill"
|
|
8
|
-
"directory": "packages/cli"
|
|
7
|
+
"url": "https://github.com/Jujulego/jill"
|
|
9
8
|
},
|
|
10
|
-
"bin": "./bin/jill.js",
|
|
11
|
-
"main": "./dist/main.js",
|
|
12
9
|
"files": [
|
|
13
10
|
"bin",
|
|
14
11
|
"dist"
|
|
15
12
|
],
|
|
13
|
+
"bin": "./bin/jill.js",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
"require": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts"
|
|
19
|
+
},
|
|
16
20
|
"scripts": {
|
|
17
|
-
"lint": "eslint
|
|
21
|
+
"lint": "eslint .",
|
|
18
22
|
"clean": "gulp clean",
|
|
19
23
|
"build": "gulp build",
|
|
20
24
|
"watch": "gulp watch",
|
|
21
|
-
"start": "ts-node src/main.tsx",
|
|
22
25
|
"test": "jest"
|
|
23
26
|
},
|
|
24
27
|
"engines": {
|
|
25
|
-
"node": "^
|
|
26
|
-
},
|
|
27
|
-
"peerDependencies": {
|
|
28
|
-
"@jujulego/jill-myr": "1.2.1"
|
|
29
|
-
},
|
|
30
|
-
"peerDependenciesMeta": {
|
|
31
|
-
"@jujulego/jill-myr": {
|
|
32
|
-
"optional": true
|
|
33
|
-
}
|
|
28
|
+
"node": "^16"
|
|
34
29
|
},
|
|
35
30
|
"dependencies": {
|
|
36
|
-
"@jujulego/
|
|
37
|
-
"@jujulego/
|
|
38
|
-
"
|
|
39
|
-
"chalk": "^4.1.
|
|
40
|
-
"graphql": "^16.0.0",
|
|
41
|
-
"graphql-request": "^4.0.0",
|
|
42
|
-
"graphql-tag": "^2.12.6",
|
|
43
|
-
"graphql-ws": "^5.5.5",
|
|
31
|
+
"@jujulego/event-tree": "^1.1.0-rc.2",
|
|
32
|
+
"@jujulego/tasks": "^1.0.0-rc.3",
|
|
33
|
+
"async-lock": "^1.3.1",
|
|
34
|
+
"chalk": "^4.1.2",
|
|
44
35
|
"ink": "^3.2.0",
|
|
45
36
|
"ink-spinner": "^4.0.3",
|
|
37
|
+
"inversify": "^6.0.1",
|
|
38
|
+
"inversify-inject-decorators": "^3.1.0",
|
|
46
39
|
"log-symbols": "^4.1.0",
|
|
47
|
-
"
|
|
40
|
+
"ms": "^2.1.3",
|
|
41
|
+
"normalize-package-data": "^4.0.0",
|
|
48
42
|
"react": "^17.0.2",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
43
|
+
"reflect-metadata": "^0.1.13",
|
|
44
|
+
"semver": "^7.3.5",
|
|
45
|
+
"slugify": "^1.6.5",
|
|
46
|
+
"tiny-glob": "^0.2.9",
|
|
47
|
+
"tree-kill": "^1.2.2",
|
|
48
|
+
"use-sync-external-store": "^1.2.0",
|
|
49
|
+
"winston": "^3.6.0",
|
|
50
|
+
"winston-transport": "^4.5.0",
|
|
51
|
+
"yargs": "^17.6.0"
|
|
54
52
|
},
|
|
55
53
|
"devDependencies": {
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"@babel/runtime": "7.17.8",
|
|
54
|
+
"@jujulego/flow": "1.1.0",
|
|
55
|
+
"@swc/core": "1.3.5",
|
|
56
|
+
"@swc/jest": "0.2.23",
|
|
57
|
+
"@types/async-lock": "1.1.5",
|
|
61
58
|
"@types/gulp": "4.0.9",
|
|
62
|
-
"@types/
|
|
63
|
-
"@types/
|
|
59
|
+
"@types/gulp-sourcemaps": "0.0.35",
|
|
60
|
+
"@types/jest": "28.1.3",
|
|
61
|
+
"@types/ms": "0.7.31",
|
|
62
|
+
"@types/node": "16.11.64",
|
|
64
63
|
"@types/normalize-package-data": "2.4.1",
|
|
65
|
-
"@types/react": "17.0.
|
|
66
|
-
"@types/
|
|
67
|
-
"@types/
|
|
68
|
-
"@
|
|
69
|
-
"@typescript-eslint/
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"eslint
|
|
73
|
-
"eslint-plugin-
|
|
74
|
-
"eslint-plugin-react
|
|
64
|
+
"@types/react": "17.0.50",
|
|
65
|
+
"@types/semver": "7.3.9",
|
|
66
|
+
"@types/use-sync-external-store": "^0.0.3",
|
|
67
|
+
"@types/yargs": "17.0.13",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "5.39.0",
|
|
69
|
+
"@typescript-eslint/parser": "5.39.0",
|
|
70
|
+
"del": "6.1.1",
|
|
71
|
+
"eslint": "8.24.0",
|
|
72
|
+
"eslint-plugin-jest": "27.0.4",
|
|
73
|
+
"eslint-plugin-react": "7.31.10",
|
|
74
|
+
"eslint-plugin-react-hooks": "4.6.0",
|
|
75
75
|
"eslint-plugin-workspaces": "0.7.0",
|
|
76
76
|
"gulp": "4.0.2",
|
|
77
77
|
"gulp-cli": "2.3.0",
|
|
78
|
+
"gulp-sourcemaps": "3.0.0",
|
|
79
|
+
"gulp-swc": "1.2.3",
|
|
80
|
+
"gulp-typescript": "6.0.0-alpha.1",
|
|
78
81
|
"ink-testing-library": "2.1.0",
|
|
79
|
-
"jest": "
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
"ts-node": "10.7.0",
|
|
85
|
-
"typescript": "4.6.2"
|
|
86
|
-
},
|
|
87
|
-
"stableVersion": "2.0.0-beta.1"
|
|
82
|
+
"jest": "28.1.2",
|
|
83
|
+
"ts-node": "10.9.1",
|
|
84
|
+
"typescript": "4.8.4",
|
|
85
|
+
"winston-transport": "4.5.0"
|
|
86
|
+
}
|
|
88
87
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import yargs from 'yargs';
|
|
3
|
-
export declare type Args<A> = yargs.ArgumentsCamelCase<A> & {
|
|
4
|
-
'--': readonly (string | number)[];
|
|
5
|
-
};
|
|
6
|
-
export declare type Builder<A> = (yargs: yargs.Argv) => yargs.Argv<A>;
|
|
7
|
-
export declare type BuilderWrapper<A> = <Args>(yargs: yargs.Argv<Args>) => yargs.Argv<Omit<Args, keyof A> & A>;
|
|
8
|
-
export interface GlobalArgs {
|
|
9
|
-
plugins: string[];
|
|
10
|
-
verbose: number;
|
|
11
|
-
}
|
|
12
|
-
export interface Command<A> {
|
|
13
|
-
id: string;
|
|
14
|
-
name: string | readonly [string, ...string[]];
|
|
15
|
-
description: string;
|
|
16
|
-
builder: Builder<A>;
|
|
17
|
-
}
|
|
18
|
-
export interface ApplicationContextState {
|
|
19
|
-
args: Args<unknown>;
|
|
20
|
-
command?: Command<unknown>;
|
|
21
|
-
}
|
|
22
|
-
export interface CommandComponent<A> extends FC {
|
|
23
|
-
command: Command<A>;
|
|
24
|
-
}
|
|
25
|
-
export declare type UseArgsHook<A> = () => Args<A & GlobalArgs>;
|
|
26
|
-
export declare const applicationDefaultState: ApplicationContextState;
|
|
27
|
-
export declare const ApplicationContext: import("react").Context<ApplicationContextState>;
|
|
28
|
-
export declare function useArgs<A>(): Args<A & GlobalArgs>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["application.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,EAAE,EAAc,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,oBAAY,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;CAAE,CAAC;AAC3F,oBAAY,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9D,oBAAY,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAEvG,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,CAAE,SAAQ,EAAE;IAC7C,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACrB;AAED,oBAAY,WAAW,CAAC,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC;AAGxD,eAAO,MAAM,uBAAuB,EAAE,uBAMrC,CAAC;AAEF,eAAO,MAAM,kBAAkB,kDAAyC,CAAC;AAGzE,wBAAgB,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,UAAU,CAAC,CAGjD","file":"application.context.d.ts","sourcesContent":["import { createContext, FC, useContext } from 'react';\nimport yargs from 'yargs';\n\n// Test\nexport type Args<A> = yargs.ArgumentsCamelCase<A> & { '--': readonly (string | number)[] };\nexport type Builder<A> = (yargs: yargs.Argv) => yargs.Argv<A>;\nexport type BuilderWrapper<A> = <Args>(yargs: yargs.Argv<Args>) => yargs.Argv<Omit<Args, keyof A> & A>;\n\nexport interface GlobalArgs {\n plugins: string[];\n verbose: number;\n}\n\nexport interface Command<A> {\n id: string;\n name: string | readonly [string, ...string[]];\n description: string;\n builder: Builder<A>;\n}\n\nexport interface ApplicationContextState {\n args: Args<unknown>;\n command?: Command<unknown>;\n}\n\nexport interface CommandComponent<A> extends FC {\n command: Command<A>;\n}\n\nexport type UseArgsHook<A> = () => Args<A & GlobalArgs>;\n\n// Context\nexport const applicationDefaultState: ApplicationContextState = {\n args: {\n '$0': '',\n '_': [],\n '--': []\n }\n};\n\nexport const ApplicationContext = createContext(applicationDefaultState);\n\n// Hooks\nexport function useArgs<A>(): Args<A & GlobalArgs> {\n const { args } = useContext(ApplicationContext);\n return args as Args<A & GlobalArgs>;\n}\n"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.applicationDefaultState = exports.ApplicationContext = void 0;
|
|
7
|
-
exports.useArgs = useArgs;
|
|
8
|
-
|
|
9
|
-
var _react = require("react");
|
|
10
|
-
|
|
11
|
-
// Context
|
|
12
|
-
const applicationDefaultState = {
|
|
13
|
-
args: {
|
|
14
|
-
'$0': '',
|
|
15
|
-
'_': [],
|
|
16
|
-
'--': []
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
exports.applicationDefaultState = applicationDefaultState;
|
|
20
|
-
const ApplicationContext = /*#__PURE__*/(0, _react.createContext)(applicationDefaultState); // Hooks
|
|
21
|
-
|
|
22
|
-
exports.ApplicationContext = ApplicationContext;
|
|
23
|
-
|
|
24
|
-
function useArgs() {
|
|
25
|
-
const {
|
|
26
|
-
args
|
|
27
|
-
} = (0, _react.useContext)(ApplicationContext);
|
|
28
|
-
return args;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=application.context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["application.context.ts"],"names":["applicationDefaultState","args","ApplicationContext","useArgs"],"mappings":";;;;;;;;AAAA;;AA+BA;AACO,MAAMA,uBAAuB,GAA4B;AAC9DC,EAAAA,IAAI,EAAE;AACJ,UAAM,EADF;AAEJ,SAAK,EAFD;AAGJ,UAAM;AAHF;AADwD,CAAzD;;AAQA,MAAMC,kBAAkB,gBAAG,0BAAcF,uBAAd,CAA3B,C,CAEP;;;;AACM,SAAUG,OAAV,GAAiB;AACrB,QAAM;AAAEF,IAAAA;AAAF,MAAW,uBAAWC,kBAAX,CAAjB;AACA,SAAOD,IAAP;AACD","file":"application.context.js","sourcesContent":["import { createContext, FC, useContext } from 'react';\nimport yargs from 'yargs';\n\n// Test\nexport type Args<A> = yargs.ArgumentsCamelCase<A> & { '--': readonly (string | number)[] };\nexport type Builder<A> = (yargs: yargs.Argv) => yargs.Argv<A>;\nexport type BuilderWrapper<A> = <Args>(yargs: yargs.Argv<Args>) => yargs.Argv<Omit<Args, keyof A> & A>;\n\nexport interface GlobalArgs {\n plugins: string[];\n verbose: number;\n}\n\nexport interface Command<A> {\n id: string;\n name: string | readonly [string, ...string[]];\n description: string;\n builder: Builder<A>;\n}\n\nexport interface ApplicationContextState {\n args: Args<unknown>;\n command?: Command<unknown>;\n}\n\nexport interface CommandComponent<A> extends FC {\n command: Command<A>;\n}\n\nexport type UseArgsHook<A> = () => Args<A & GlobalArgs>;\n\n// Context\nexport const applicationDefaultState: ApplicationContextState = {\n args: {\n '$0': '',\n '_': [],\n '--': []\n }\n};\n\nexport const ApplicationContext = createContext(applicationDefaultState);\n\n// Hooks\nexport function useArgs<A>(): Args<A & GlobalArgs> {\n const { args } = useContext(ApplicationContext);\n return args as Args<A & GlobalArgs>;\n}\n"]}
|
package/dist/application.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["application.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAgC,MAAM,OAAO,CAAC;AAIzD,OAAO,EAIC,gBAAgB,EAEvB,MAAM,uBAAuB,CAAC;AAG/B,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAA;CACtC;AAGD,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAuE5C,CAAC","file":"application.d.ts","sourcesContent":["import { logger } from '@jujulego/jill-core';\nimport { FC, useEffect, useMemo, useState } from 'react';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport {\n ApplicationContext,\n ApplicationContextState,\n applicationDefaultState,\n Args, CommandComponent,\n GlobalArgs\n} from './application.context';\n\n// Types\nexport interface ApplicationProps {\n name: string;\n commands: CommandComponent<unknown>[]\n}\n\n// Component\nexport const Application: FC<ApplicationProps> = ({ name, commands }) => {\n // State\n const [state, setState] = useState<ApplicationContextState>(applicationDefaultState);\n\n // Memo\n const Command = useMemo(() => {\n return commands.find((cmd) => cmd.command.id === state.command?.id);\n }, [commands, state.command?.id]);\n\n // Effects\n useEffect(() => void (async () => {\n // Config yargs\n const parser = yargs(hideBin(process.argv))\n .parserConfiguration({\n 'populate--': true,\n })\n .scriptName(name)\n .pkgConf(name)\n .option('plugins', {\n type: 'array',\n default: [] as string[],\n description: 'Plugins to load',\n })\n .option('verbose', {\n alias: 'v',\n type: 'count',\n description: 'Set verbosity level (1 for verbose, 2 for debug)',\n });\n\n // Parse global options\n const { verbose, plugins } = await parser.help(false).parse();\n\n // Setup logger verbosity\n if (verbose === 1) {\n logger.level = 'verbose';\n } else if (verbose >= 2) {\n logger.level = 'debug';\n }\n\n // Define core commands\n for (const { command } of commands) {\n parser.command(\n command.name,\n command.description,\n (y) => command.builder(y),\n (args) => {\n setState((old) => ({\n ...old,\n args: args as Args<GlobalArgs>,\n command\n }));\n }\n );\n }\n\n // Parse to run command\n parser.strictCommands()\n .help()\n .parse();\n })(), [name, commands]);\n\n // Render\n if (!Command) {\n return null;\n }\n\n return (\n <ApplicationContext.Provider value={state}>\n <Command />\n </ApplicationContext.Provider>\n );\n};\n"]}
|
package/dist/application.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Application = void 0;
|
|
7
|
-
|
|
8
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
-
|
|
10
|
-
var _jillCore = require("@jujulego/jill-core");
|
|
11
|
-
|
|
12
|
-
var _react = require("react");
|
|
13
|
-
|
|
14
|
-
var _yargs = _interopRequireDefault(require("yargs"));
|
|
15
|
-
|
|
16
|
-
var _helpers = require("yargs/helpers");
|
|
17
|
-
|
|
18
|
-
var _application = require("./application.context");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
23
|
-
function adopt(value) {
|
|
24
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
25
|
-
resolve(value);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
30
|
-
function fulfilled(value) {
|
|
31
|
-
try {
|
|
32
|
-
step(generator.next(value));
|
|
33
|
-
} catch (e) {
|
|
34
|
-
reject(e);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function rejected(value) {
|
|
39
|
-
try {
|
|
40
|
-
step(generator["throw"](value));
|
|
41
|
-
} catch (e) {
|
|
42
|
-
reject(e);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function step(result) {
|
|
47
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// Component
|
|
55
|
-
const Application = ({
|
|
56
|
-
name,
|
|
57
|
-
commands
|
|
58
|
-
}) => {
|
|
59
|
-
var _a; // State
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const [state, setState] = (0, _react.useState)(_application.applicationDefaultState); // Memo
|
|
63
|
-
|
|
64
|
-
const Command = (0, _react.useMemo)(() => {
|
|
65
|
-
return commands.find(cmd => {
|
|
66
|
-
var _a;
|
|
67
|
-
|
|
68
|
-
return cmd.command.id === ((_a = state.command) === null || _a === void 0 ? void 0 : _a.id);
|
|
69
|
-
});
|
|
70
|
-
}, [commands, (_a = state.command) === null || _a === void 0 ? void 0 : _a.id]); // Effects
|
|
71
|
-
|
|
72
|
-
(0, _react.useEffect)(() => void (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
-
// Config yargs
|
|
74
|
-
const parser = (0, _yargs.default)((0, _helpers.hideBin)(process.argv)).parserConfiguration({
|
|
75
|
-
'populate--': true
|
|
76
|
-
}).scriptName(name).pkgConf(name).option('plugins', {
|
|
77
|
-
type: 'array',
|
|
78
|
-
default: [],
|
|
79
|
-
description: 'Plugins to load'
|
|
80
|
-
}).option('verbose', {
|
|
81
|
-
alias: 'v',
|
|
82
|
-
type: 'count',
|
|
83
|
-
description: 'Set verbosity level (1 for verbose, 2 for debug)'
|
|
84
|
-
}); // Parse global options
|
|
85
|
-
|
|
86
|
-
const {
|
|
87
|
-
verbose,
|
|
88
|
-
plugins
|
|
89
|
-
} = yield parser.help(false).parse(); // Setup logger verbosity
|
|
90
|
-
|
|
91
|
-
if (verbose === 1) {
|
|
92
|
-
_jillCore.logger.level = 'verbose';
|
|
93
|
-
} else if (verbose >= 2) {
|
|
94
|
-
_jillCore.logger.level = 'debug';
|
|
95
|
-
} // Define core commands
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
for (const {
|
|
99
|
-
command
|
|
100
|
-
} of commands) {
|
|
101
|
-
parser.command(command.name, command.description, y => command.builder(y), args => {
|
|
102
|
-
setState(old => Object.assign(Object.assign({}, old), {
|
|
103
|
-
args: args,
|
|
104
|
-
command
|
|
105
|
-
}));
|
|
106
|
-
});
|
|
107
|
-
} // Parse to run command
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
parser.strictCommands().help().parse();
|
|
111
|
-
}))(), [name, commands]); // Render
|
|
112
|
-
|
|
113
|
-
if (!Command) {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return (0, _jsxRuntime.jsx)(_application.ApplicationContext.Provider, Object.assign({
|
|
118
|
-
value: state
|
|
119
|
-
}, {
|
|
120
|
-
children: (0, _jsxRuntime.jsx)(Command, {})
|
|
121
|
-
}));
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
exports.Application = Application;
|
|
125
|
-
//# sourceMappingURL=application.js.map
|
package/dist/application.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["application.js","application.tsx"],"names":["__awaiter","thisArg","_arguments","P","generator","adopt","value","resolve","Promise","reject","fulfilled","step","next","e","rejected","result","done","then","apply","Application","name","commands","_a","state","setState","applicationDefaultState","Command","find","cmd","command","id","parser","process","argv","parserConfiguration","scriptName","pkgConf","option","type","default","description","alias","verbose","plugins","help","parse","logger","level","y","builder","args","old","Object","assign","strictCommands","ApplicationContext","Provider","children"],"mappings":";;;;;;;AASA;;ACTA;;AACA;;AACA;;AACA;;AAEA;;;;ADLA,IAAIA,SAAS,GAAI,UAAQ,SAAKA,SAAd,IAA4B,UAAUC,OAAV,EAAmBC,UAAnB,EAA+BC,CAA/B,EAAkCC,SAAlC,EA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AAAA,OAAF;AAAWC,MAAAA;AAAX,QAAuB,MAAMZ,MAAM,CAACa,IAAP,CAAY,KAAZ,EAAmBC,KAAnB,EAAnC,CApB+B,CAsB/B;;AACA,QAAIH,OAAO,KAAK,CAAhB,EAAmB;AACjBI,uBAAOC,KAAP,GAAe,SAAf;AACD,KAFD,MAEO,IAAIL,OAAO,IAAI,CAAf,EAAkB;AACvBI,uBAAOC,KAAP,GAAe,OAAf;AACD,KA3B8B,CA6B/B;;;AACA,SAAK,MAAM;AAAElB,MAAAA;AAAF,KAAX,IAA0BR,QAA1B,EAAoC;AAClCU,MAAAA,MAAM,CAACF,OAAP,CACEA,OAAO,CAACT,IADV,EAEES,OAAO,CAACW,WAFV,EAGGQ,CAAD,IAAOnB,OAAO,CAACoB,OAAR,CAAgBD,CAAhB,CAHT,EAIGE,IAAD,IAAS;AACP1B,QAAAA,QAAQ,CAAE2B,GAAD,IAASC,MAAA,CAAAC,MAAA,CAAAD,MAAA,CAAAC,MAAA,CAAA,EAAA,EACbF,GADa,CAAA,EACV;AACND,UAAAA,IAAI,EAAEA,IADA;AAENrB,UAAAA;AAFM,SADU,CAAV,CAAR;AAKD,OAVH;AAYD,KA3C8B,CA6C/B;;;AACAE,IAAAA,MAAM,CAACuB,cAAP,GACGV,IADH,GAEGC,KAFH;AAGD,GAjDgC,CAAZ,GAArB,EAiDM,CAACzB,IAAD,EAAOC,QAAP,CAjDN,EAVsE,CA6DtE;;AACA,MAAI,CAACK,OAAL,EAAc;AACZ,WAAO,IAAP;AACD;;AAED,SACE,qBAAC6B,gCAAmBC,QAApB,EAA4BJ,MAAA,CAAAC,MAAA,CAAA;AAAC/C,IAAAA,KAAK,EAAEiB;AAAR,GAAA,EAAa;AAAAkC,IAAAA,QAAA,EACvC,qBAAC/B,OAAD,EAAQ,EAAR;AADuC,GAAb,CAA5B,CADF;AAKD,CAvEM","file":"application.js","sourcesContent":["var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nimport { logger } from '@jujulego/jill-core';\nimport { useEffect, useMemo, useState } from 'react';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { ApplicationContext, applicationDefaultState } from './application.context';\n// Component\nexport const Application = ({ name, commands }) => {\n var _a;\n // State\n const [state, setState] = useState(applicationDefaultState);\n // Memo\n const Command = useMemo(() => {\n return commands.find((cmd) => { var _a; return cmd.command.id === ((_a = state.command) === null || _a === void 0 ? void 0 : _a.id); });\n }, [commands, (_a = state.command) === null || _a === void 0 ? void 0 : _a.id]);\n // Effects\n useEffect(() => void (() => __awaiter(void 0, void 0, void 0, function* () {\n // Config yargs\n const parser = yargs(hideBin(process.argv))\n .parserConfiguration({\n 'populate--': true,\n })\n .scriptName(name)\n .pkgConf(name)\n .option('plugins', {\n type: 'array',\n default: [],\n description: 'Plugins to load',\n })\n .option('verbose', {\n alias: 'v',\n type: 'count',\n description: 'Set verbosity level (1 for verbose, 2 for debug)',\n });\n // Parse global options\n const { verbose, plugins } = yield parser.help(false).parse();\n // Setup logger verbosity\n if (verbose === 1) {\n logger.level = 'verbose';\n }\n else if (verbose >= 2) {\n logger.level = 'debug';\n }\n // Define core commands\n for (const { command } of commands) {\n parser.command(command.name, command.description, (y) => command.builder(y), (args) => {\n setState((old) => (Object.assign(Object.assign({}, old), { args: args, command })));\n });\n }\n // Parse to run command\n parser.strictCommands()\n .help()\n .parse();\n }))(), [name, commands]);\n // Render\n if (!Command) {\n return null;\n }\n return (_jsx(ApplicationContext.Provider, Object.assign({ value: state }, { children: _jsx(Command, {}) })));\n};","import { logger } from '@jujulego/jill-core';\nimport { FC, useEffect, useMemo, useState } from 'react';\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nimport {\n ApplicationContext,\n ApplicationContextState,\n applicationDefaultState,\n Args, CommandComponent,\n GlobalArgs\n} from './application.context';\n\n// Types\nexport interface ApplicationProps {\n name: string;\n commands: CommandComponent<unknown>[]\n}\n\n// Component\nexport const Application: FC<ApplicationProps> = ({ name, commands }) => {\n // State\n const [state, setState] = useState<ApplicationContextState>(applicationDefaultState);\n\n // Memo\n const Command = useMemo(() => {\n return commands.find((cmd) => cmd.command.id === state.command?.id);\n }, [commands, state.command?.id]);\n\n // Effects\n useEffect(() => void (async () => {\n // Config yargs\n const parser = yargs(hideBin(process.argv))\n .parserConfiguration({\n 'populate--': true,\n })\n .scriptName(name)\n .pkgConf(name)\n .option('plugins', {\n type: 'array',\n default: [] as string[],\n description: 'Plugins to load',\n })\n .option('verbose', {\n alias: 'v',\n type: 'count',\n description: 'Set verbosity level (1 for verbose, 2 for debug)',\n });\n\n // Parse global options\n const { verbose, plugins } = await parser.help(false).parse();\n\n // Setup logger verbosity\n if (verbose === 1) {\n logger.level = 'verbose';\n } else if (verbose >= 2) {\n logger.level = 'debug';\n }\n\n // Define core commands\n for (const { command } of commands) {\n parser.command(\n command.name,\n command.description,\n (y) => command.builder(y),\n (args) => {\n setState((old) => ({\n ...old,\n args: args as Args<GlobalArgs>,\n command\n }));\n }\n );\n }\n\n // Parse to run command\n parser.strictCommands()\n .help()\n .parse();\n })(), [name, commands]);\n\n // Render\n if (!Command) {\n return null;\n }\n\n return (\n <ApplicationContext.Provider value={state}>\n <Command />\n </ApplicationContext.Provider>\n );\n};\n"]}
|
package/dist/command.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { Command, CommandComponent, UseArgsHook } from './application.context';
|
|
3
|
-
export declare type CommandMetadata<A> = Omit<Command<A>, 'id'>;
|
|
4
|
-
export interface CommandUtils<A> {
|
|
5
|
-
useArgs: UseArgsHook<A>;
|
|
6
|
-
wrapper: (Component: FC) => CommandComponent<A>;
|
|
7
|
-
}
|
|
8
|
-
export declare function command<A>(command: CommandMetadata<A>): CommandUtils<A>;
|
package/dist/command.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAE3B,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAW,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGxF,oBAAY,eAAe,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;AAEvD,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACxB,OAAO,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,gBAAgB,CAAC,CAAC,CAAC,CAAC;CACjD;AAGD,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAcvE","file":"command.d.ts","sourcesContent":["import { FC } from 'react';\n\nimport { Command, CommandComponent, useArgs, UseArgsHook } from './application.context';\n\n// Types\nexport type CommandMetadata<A> = Omit<Command<A>, 'id'>\n\nexport interface CommandUtils<A> {\n useArgs: UseArgsHook<A>;\n wrapper: (Component: FC) => CommandComponent<A>;\n}\n\n// Generate HOC & Hook for command components\nexport function command<A>(command: CommandMetadata<A>): CommandUtils<A> {\n return {\n useArgs: () => useArgs<A>(),\n wrapper: (Component: FC): CommandComponent<A> => {\n Component.displayName = `command(${Component.displayName || Component.name})`;\n\n return Object.assign(Component, {\n command: {\n ...command,\n id: typeof command.name === 'string' ? command.name : command.name[0],\n }\n });\n }\n };\n}\n"]}
|
package/dist/command.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.command = command;
|
|
7
|
-
|
|
8
|
-
var _application = require("./application.context");
|
|
9
|
-
|
|
10
|
-
// Generate HOC & Hook for command components
|
|
11
|
-
function command(command) {
|
|
12
|
-
return {
|
|
13
|
-
useArgs: () => (0, _application.useArgs)(),
|
|
14
|
-
wrapper: Component => {
|
|
15
|
-
Component.displayName = `command(${Component.displayName || Component.name})`;
|
|
16
|
-
return Object.assign(Component, {
|
|
17
|
-
command: Object.assign(Object.assign({}, command), {
|
|
18
|
-
id: typeof command.name === 'string' ? command.name : command.name[0]
|
|
19
|
-
})
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=command.js.map
|
package/dist/command.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["command.ts"],"names":["command","useArgs","wrapper","Component","displayName","name","Object","assign","id"],"mappings":";;;;;;;AAEA;;AAUA;AACM,SAAUA,OAAV,CAAqBA,OAArB,EAAgD;AACpD,SAAO;AACLC,IAAAA,OAAO,EAAE,MAAM,2BADV;AAELC,IAAAA,OAAO,EAAGC,SAAD,IAAuC;AAC9CA,MAAAA,SAAS,CAACC,WAAV,GAAwB,WAAWD,SAAS,CAACC,WAAV,IAAyBD,SAAS,CAACE,IAAI,GAA1E;AAEA,aAAOC,MAAM,CAACC,MAAP,CAAcJ,SAAd,EAAyB;AAC9BH,QAAAA,OAAO,EAAAM,MAAA,CAAAC,MAAA,CAAAD,MAAA,CAAAC,MAAA,CAAA,EAAA,EACFP,OADE,CAAA,EACK;AACVQ,UAAAA,EAAE,EAAE,OAAOR,OAAO,CAACK,IAAf,KAAwB,QAAxB,GAAmCL,OAAO,CAACK,IAA3C,GAAkDL,OAAO,CAACK,IAAR,CAAa,CAAb;AAD5C,SADL;AADuB,OAAzB,CAAP;AAMD;AAXI,GAAP;AAaD","file":"command.js","sourcesContent":["import { FC } from 'react';\n\nimport { Command, CommandComponent, useArgs, UseArgsHook } from './application.context';\n\n// Types\nexport type CommandMetadata<A> = Omit<Command<A>, 'id'>\n\nexport interface CommandUtils<A> {\n useArgs: UseArgsHook<A>;\n wrapper: (Component: FC) => CommandComponent<A>;\n}\n\n// Generate HOC & Hook for command components\nexport function command<A>(command: CommandMetadata<A>): CommandUtils<A> {\n return {\n useArgs: () => useArgs<A>(),\n wrapper: (Component: FC): CommandComponent<A> => {\n Component.displayName = `command(${Component.displayName || Component.name})`;\n\n return Object.assign(Component, {\n command: {\n ...command,\n id: typeof command.name === 'string' ? command.name : command.name[0],\n }\n });\n }\n };\n}\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { WorkspaceDepsMode } from '@jujulego/jill-core';
|
|
2
|
-
export declare const EachCommand: import("../application.context").CommandComponent<Omit<{
|
|
3
|
-
script: string;
|
|
4
|
-
} & {
|
|
5
|
-
"deps-mode": WorkspaceDepsMode;
|
|
6
|
-
} & {
|
|
7
|
-
private: boolean | undefined;
|
|
8
|
-
} & {
|
|
9
|
-
affected: string | undefined;
|
|
10
|
-
} & {
|
|
11
|
-
"affected-rev-sort": string | undefined;
|
|
12
|
-
} & {
|
|
13
|
-
"affected-rev-fallback": string;
|
|
14
|
-
}, "project" | "package-manager"> & {
|
|
15
|
-
project: string | undefined;
|
|
16
|
-
} & {
|
|
17
|
-
"package-manager": import("@jujulego/jill-core").PackageManager | undefined;
|
|
18
|
-
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["commands/each.command.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAgDjE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;EA+CtB,CAAC","file":"each.command.d.ts","sourcesContent":["import { AffectedFilter, Filter, Pipeline, TaskSetSpinner } from '@jujulego/jill-common';\nimport { TaskSet, WorkspaceDepsMode } from '@jujulego/jill-core';\nimport { useApp } from 'ink';\nimport { useEffect, useRef } from 'react';\n\nimport { command } from '../command';\nimport { useProject, withProject } from '../wrappers/project.wrapper';\n\n// Command\nconst { wrapper, useArgs } = withProject(command({\n name: 'each <script>',\n description: 'Run script on selected workspaces',\n builder: yargs => yargs\n .positional('script', { type: 'string', demandOption: true })\n .option('deps-mode', {\n choice: ['all', 'prod', 'none'],\n default: 'all' as WorkspaceDepsMode,\n desc: 'Dependency selection mode:\\n' +\n ' - all = dependencies AND devDependencies\\n' +\n ' - prod = dependencies\\n' +\n ' - none = nothing'\n })\n .option('private', {\n type: 'boolean',\n group: 'Filters:',\n desc: 'Print only private workspaces',\n })\n .option('affected', {\n alias: 'a',\n type: 'string',\n coerce: (rev: string) => rev === '' ? 'master' : rev,\n group: 'Affected:',\n desc: 'Print only affected workspaces towards given git revision. If no revision is given, it will check towards master.\\n' +\n 'Replaces %name by workspace name.',\n })\n .option('affected-rev-sort', {\n type: 'string',\n group: 'Affected:',\n desc: 'Sort applied to git tag / git branch command',\n })\n .option('affected-rev-fallback', {\n type: 'string',\n default: 'master',\n group: 'Affected:',\n desc: 'Fallback revision, used if no revision matching the given format is found',\n })\n}));\n\n// Component\nexport const EachCommand = wrapper(function EachCommand() {\n const args = useArgs();\n const project = useProject();\n const { exit } = useApp();\n\n // Refs\n const tasks = useRef(new TaskSet());\n\n // Effects\n useEffect(() => void (async () => {\n // Setup pipeline\n const pipeline = new Pipeline();\n pipeline.add(Filter.scripts([args.script]));\n\n if (args.private !== undefined) {\n pipeline.add(Filter.privateWorkspace(args.private));\n }\n\n if (args.affected !== undefined) {\n pipeline.add(new AffectedFilter(\n args.affected,\n args.affectedRevFallback,\n args.affectedRevSort\n ));\n }\n\n // Filter and create tasks\n for await (const wks of pipeline.filter(project.workspaces())) {\n tasks.current.add(await wks.run(args.script, args['--']?.map(arg => arg.toString()), {\n buildDeps: args.depsMode\n }));\n }\n\n tasks.current.start();\n\n // Result end code\n const [result] = await tasks.current.waitFor('finished');\n\n if (result.failed) {\n exit(new Error('Some tasks has failed'));\n }\n })(), [args, project, exit]);\n\n // Render\n return (\n <TaskSetSpinner taskSet={tasks.current} />\n );\n});\n"]}
|