@jujulego/jill 1.1.18 → 2.0.0-beta.1
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/dist/application.context.d.ts +28 -0
- package/dist/application.context.d.ts.map +1 -0
- package/dist/application.context.js +30 -0
- package/dist/application.context.js.map +1 -0
- package/dist/application.d.ts +7 -0
- package/dist/application.d.ts.map +1 -0
- package/dist/application.js +125 -0
- package/dist/application.js.map +1 -0
- package/dist/command.d.ts +7 -20
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +17 -62
- package/dist/command.js.map +1 -0
- package/dist/commands/each.command.d.ts +14 -13
- package/dist/commands/each.command.d.ts.map +1 -0
- package/dist/commands/each.command.js +144 -81
- package/dist/commands/each.command.js.map +1 -0
- package/dist/commands/list.command.d.ts +17 -14
- package/dist/commands/list.command.d.ts.map +1 -0
- package/dist/commands/list.command.js +199 -122
- package/dist/commands/list.command.js.map +1 -0
- package/dist/commands/run.command.d.ts +10 -11
- package/dist/commands/run.command.d.ts.map +1 -0
- package/dist/commands/run.command.js +73 -39
- package/dist/commands/run.command.js.map +1 -0
- package/dist/commands/tree.command.d.ts +7 -0
- package/dist/commands/tree.command.d.ts.map +1 -0
- package/dist/commands/tree.command.js +35 -0
- package/dist/commands/tree.command.js.map +1 -0
- package/dist/components/List.d.ts +9 -0
- package/dist/components/List.d.ts.map +1 -0
- package/dist/components/List.js +57 -0
- package/dist/components/List.js.map +1 -0
- package/dist/components/StaticLogs.d.ts +2 -0
- package/dist/components/StaticLogs.d.ts.map +1 -0
- package/dist/components/StaticLogs.js +77 -0
- package/dist/components/StaticLogs.js.map +1 -0
- package/dist/components/TaskSetSpinner.d.ts +6 -0
- package/dist/components/TaskSetSpinner.d.ts.map +1 -0
- package/dist/components/TaskSetSpinner.js +41 -0
- package/dist/components/TaskSetSpinner.js.map +1 -0
- package/dist/components/TaskSpinner.d.ts +6 -0
- package/dist/components/TaskSpinner.d.ts.map +1 -0
- package/dist/components/TaskSpinner.js +72 -0
- package/dist/components/TaskSpinner.js.map +1 -0
- package/dist/components/WorkspaceTree.d.ts +8 -0
- package/dist/components/WorkspaceTree.d.ts.map +1 -0
- package/dist/components/WorkspaceTree.js +153 -0
- package/dist/components/WorkspaceTree.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +48 -21
- package/dist/main.js.map +1 -0
- package/dist/wrapper.d.ts +6 -0
- package/dist/wrapper.d.ts.map +1 -0
- package/dist/wrapper.js +30 -0
- package/dist/wrapper.js.map +1 -0
- package/dist/wrappers/project.wrapper.d.ts +7 -0
- package/dist/wrappers/project.wrapper.d.ts.map +1 -0
- package/dist/wrappers/project.wrapper.js +105 -0
- package/dist/wrappers/project.wrapper.js.map +1 -0
- package/dist/wrappers/workspace.wrapper.d.ts +5 -0
- package/dist/wrappers/workspace.wrapper.d.ts.map +1 -0
- package/dist/wrappers/workspace.wrapper.js +108 -0
- package/dist/wrappers/workspace.wrapper.js.map +1 -0
- package/package.json +43 -30
- package/dist/base.command.d.ts +0 -8
- package/dist/base.command.js +0 -33
- package/dist/commands/info.command.d.ts +0 -9
- package/dist/commands/info.command.js +0 -83
- package/dist/filters/affected.d.ts +0 -10
- package/dist/filters/affected.js +0 -80
- package/dist/filters/filter.d.ts +0 -8
- package/dist/filters/filter.js +0 -36
- package/dist/filters/index.d.ts +0 -2
- package/dist/filters/index.js +0 -22
- package/dist/logger.d.ts +0 -15
- package/dist/logger.js +0 -99
- package/dist/myr/commands/kill.command.d.ts +0 -11
- package/dist/myr/commands/kill.command.js +0 -52
- package/dist/myr/commands/list.command.d.ts +0 -18
- package/dist/myr/commands/list.command.js +0 -127
- package/dist/myr/commands/logs.command.d.ts +0 -11
- package/dist/myr/commands/logs.command.js +0 -83
- package/dist/myr/commands/spawn.command.d.ts +0 -11
- package/dist/myr/commands/spawn.command.js +0 -45
- package/dist/myr/commands/stop.command.d.ts +0 -7
- package/dist/myr/commands/stop.command.js +0 -43
- package/dist/myr/myr-client.d.ts +0 -22
- package/dist/myr/myr-client.js +0 -234
- package/dist/myr/myr.command.d.ts +0 -8
- package/dist/myr/myr.command.js +0 -46
- package/dist/myr/myr.process.d.ts +0 -1
- package/dist/myr/myr.process.js +0 -43
- package/dist/myr/watch.command.d.ts +0 -13
- package/dist/myr/watch.command.js +0 -87
- package/dist/pipeline.d.ts +0 -9
- package/dist/pipeline.js +0 -53
- package/dist/plugin.d.ts +0 -11
- package/dist/plugin.js +0 -40
- package/dist/project.command.d.ts +0 -13
- package/dist/project.command.js +0 -58
- package/dist/task-logger.d.ts +0 -14
- package/dist/task-logger.js +0 -66
- package/dist/utils/cli-list.d.ts +0 -15
- package/dist/utils/cli-list.js +0 -87
- package/dist/workspace.command.d.ts +0 -12
- package/dist/workspace.command.js +0 -55
|
@@ -0,0 +1,28 @@
|
|
|
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>;
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1 @@
|
|
|
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"]}
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,EAA6C;AACrF,WAASC,KAAT,CAAeC,KAAf,EAAsB;AAAE,WAAOA,KAAK,YAAYH,CAAjB,GAAqBG,KAArB,GAA6B,IAAIH,CAAJ,CAAM,UAAUI,OAAV,EAAmB;AAAEA,MAAAA,OAAO,CAACD,KAAD,CAAP;AAAiB,KAA5C,CAApC;AAAoF;;AAC5G,SAAO,KAAKH,CAAC,KAAKA,CAAC,GAAGK,OAAT,CAAN,EAAyB,UAAUD,OAAV,EAAmBE,MAAnB,EAA2B;AACvD,aAASC,SAAT,CAAmBJ,KAAnB,EAA0B;AAAE,UAAI;AAAEK,QAAAA,IAAI,CAACP,SAAS,CAACQ,IAAV,CAAeN,KAAf,CAAD,CAAJ;AAA8B,OAApC,CAAqC,OAAOO,CAAP,EAAU;AAAEJ,QAAAA,MAAM,CAACI,CAAD,CAAN;AAAY;AAAE;;AAC3F,aAASC,QAAT,CAAkBR,KAAlB,EAAyB;AAAE,UAAI;AAAEK,QAAAA,IAAI,CAACP,SAAS,CAAC,OAAD,CAAT,CAAmBE,KAAnB,CAAD,CAAJ;AAAkC,OAAxC,CAAyC,OAAOO,CAAP,EAAU;AAAEJ,QAAAA,MAAM,CAACI,CAAD,CAAN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,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
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare class Exit extends Error {
|
|
8
|
-
readonly code: number;
|
|
9
|
-
constructor(code?: number);
|
|
10
|
-
}
|
|
11
|
-
export declare abstract class Command<A = unknown> {
|
|
12
|
-
readonly logger: import("winston").Logger;
|
|
13
|
-
readonly spinner: import("ora").Ora;
|
|
14
|
-
protected abstract define<T, U>(builder: Builder<T, U>): Builder<T, U & A>;
|
|
15
|
-
protected abstract run(args: Arguments<A>): Awaitable<number | void>;
|
|
16
|
-
setup<T>(yargs: yargs.Argv<T>): yargs.Argv<T>;
|
|
17
|
-
private _wrapper;
|
|
18
|
-
log(msg: string): void;
|
|
19
|
-
abstract get name(): string | readonly string[];
|
|
20
|
-
abstract get description(): string;
|
|
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>;
|
|
21
7
|
}
|
|
8
|
+
export declare function command<A>(command: CommandMetadata<A>): CommandUtils<A>;
|
|
@@ -0,0 +1 @@
|
|
|
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
CHANGED
|
@@ -3,67 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
constructor(code = 1) {
|
|
22
|
-
super();
|
|
23
|
-
this.code = code;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
} // Command
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
exports.Exit = Exit;
|
|
30
|
-
|
|
31
|
-
class Command {
|
|
32
|
-
constructor() {
|
|
33
|
-
_defineProperty(this, "logger", _jillCore.logger);
|
|
34
|
-
|
|
35
|
-
_defineProperty(this, "spinner", _logger.transport.spinner);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
setup(yargs) {
|
|
39
|
-
yargs.command(this.name, this.description, y => this.define(_ => _)(y), a => this._wrapper(a));
|
|
40
|
-
return yargs;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async _wrapper(args) {
|
|
44
|
-
try {
|
|
45
|
-
const exit = await this.run(args);
|
|
46
|
-
process.exit(exit ?? 0);
|
|
47
|
-
} catch (err) {
|
|
48
|
-
if (err instanceof Exit) {
|
|
49
|
-
process.exit(err.code);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.spinner.fail(err.message);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
log(msg) {
|
|
58
|
-
if (this.spinner.isSpinning) {
|
|
59
|
-
this.spinner.clear();
|
|
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
|
+
});
|
|
60
21
|
}
|
|
61
|
-
|
|
62
|
-
process.stdout.write(msg + '\n');
|
|
63
|
-
} // Properties
|
|
64
|
-
|
|
65
|
-
|
|
22
|
+
};
|
|
66
23
|
}
|
|
67
|
-
|
|
68
|
-
exports.Command = Command;
|
|
69
|
-
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNvbW1hbmQudHMiXSwibmFtZXMiOlsiRXhpdCIsIkVycm9yIiwiY29uc3RydWN0b3IiLCJjb2RlIiwiQ29tbWFuZCIsImxvZ2dlciIsInRyYW5zcG9ydCIsInNwaW5uZXIiLCJzZXR1cCIsInlhcmdzIiwiY29tbWFuZCIsIm5hbWUiLCJkZXNjcmlwdGlvbiIsInkiLCJkZWZpbmUiLCJfIiwiYSIsIl93cmFwcGVyIiwiYXJncyIsImV4aXQiLCJydW4iLCJwcm9jZXNzIiwiZXJyIiwiZmFpbCIsIm1lc3NhZ2UiLCJsb2ciLCJtc2ciLCJpc1NwaW5uaW5nIiwiY2xlYXIiLCJzdGRvdXQiLCJ3cml0ZSJdLCJtYXBwaW5ncyI6Ijs7Ozs7OztBQUFBOztBQUNBOztBQUVBOzs7Ozs7QUFPQTtBQUNPLE1BQU1BLElBQU4sU0FBbUJDLEtBQW5CLENBQXlCO0FBQzlCO0FBQ0FDLEVBQUFBLFdBQVcsQ0FBVUMsSUFBSSxHQUFHLENBQWpCLEVBQW9CO0FBQzdCO0FBRDZCLFNBQVZBLElBQVUsR0FBVkEsSUFBVTtBQUU5Qjs7QUFKNkIsQyxDQU9oQzs7Ozs7QUFDTyxNQUFlQyxPQUFmLENBQW9DO0FBQUE7QUFBQSxvQ0FFdkJDLGdCQUZ1Qjs7QUFBQSxxQ0FHdEJDLGtCQUFVQyxPQUhZO0FBQUE7O0FBU3pDQyxFQUFBQSxLQUFLLENBQUlDLEtBQUosRUFBeUM7QUFDNUNBLElBQUFBLEtBQUssQ0FBQ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5kLmpzIn0=
|
|
24
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,17 +1,18 @@
|
|
|
1
1
|
import { WorkspaceDepsMode } from '@jujulego/jill-core';
|
|
2
|
-
|
|
3
|
-
import { ProjectArgs, ProjectCommand } from '../project.command';
|
|
4
|
-
export interface EachArgs extends ProjectArgs {
|
|
2
|
+
export declare const EachCommand: import("../application.context").CommandComponent<Omit<{
|
|
5
3
|
script: string;
|
|
6
|
-
|
|
4
|
+
} & {
|
|
5
|
+
"deps-mode": WorkspaceDepsMode;
|
|
6
|
+
} & {
|
|
7
7
|
private: boolean | undefined;
|
|
8
|
+
} & {
|
|
8
9
|
affected: string | undefined;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
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
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["commands/each.command.tsx"],"names":[],"mappings":"AACA,OAAO,EAAW,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAiDjE,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;EA+CtB,CAAC","file":"each.command.d.ts","sourcesContent":["import { AffectedFilter, Filter, Pipeline } 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 { TaskSetSpinner } from '../components/TaskSetSpinner';\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]);\n\n // Render\n return (\n <TaskSetSpinner taskSet={tasks.current} />\n );\n});\n"]}
|