@jujulego/jill 1.2.0 → 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 +8 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +24 -0
- package/dist/command.js.map +1 -0
- package/dist/commands/each.command.d.ts +14 -12
- package/dist/commands/each.command.d.ts.map +1 -1
- package/dist/commands/each.command.js +91 -116
- package/dist/commands/each.command.js.map +1 -1
- package/dist/commands/list.command.d.ts +17 -13
- package/dist/commands/list.command.d.ts.map +1 -1
- package/dist/commands/list.command.js +148 -145
- package/dist/commands/list.command.js.map +1 -1
- package/dist/commands/run.command.d.ts +10 -10
- package/dist/commands/run.command.d.ts.map +1 -1
- package/dist/commands/run.command.js +46 -63
- package/dist/commands/run.command.js.map +1 -1
- 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 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +26 -16
- package/dist/main.js.map +1 -1
- 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 +34 -24
- package/dist/commands/info.command.d.ts +0 -8
- package/dist/commands/info.command.d.ts.map +0 -1
- package/dist/commands/info.command.js +0 -178
- package/dist/commands/info.command.js.map +0 -1
- package/dist/core.plugin.d.ts +0 -2
- package/dist/core.plugin.d.ts.map +0 -1
- package/dist/core.plugin.js +0 -22
- package/dist/core.plugin.js.map +0 -1
- package/dist/task-logger.d.ts +0 -14
- package/dist/task-logger.d.ts.map +0 -1
- package/dist/task-logger.js +0 -76
- package/dist/task-logger.js.map +0 -1
|
@@ -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":"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","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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
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>;
|
|
@@ -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
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
|
|
@@ -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,16 +1,18 @@
|
|
|
1
|
-
import { Arguments, Builder, ProjectArgs, ProjectCommand } from '@jujulego/jill-common';
|
|
2
1
|
import { WorkspaceDepsMode } from '@jujulego/jill-core';
|
|
3
|
-
export
|
|
2
|
+
export declare const EachCommand: import("../application.context").CommandComponent<Omit<{
|
|
4
3
|
script: string;
|
|
5
|
-
|
|
4
|
+
} & {
|
|
5
|
+
"deps-mode": WorkspaceDepsMode;
|
|
6
|
+
} & {
|
|
6
7
|
private: boolean | undefined;
|
|
8
|
+
} & {
|
|
7
9
|
affected: string | undefined;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["commands/each.command.
|
|
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"]}
|
|
@@ -5,11 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.EachCommand = void 0;
|
|
7
7
|
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
|
|
8
10
|
var _jillCommon = require("@jujulego/jill-common");
|
|
9
11
|
|
|
10
12
|
var _jillCore = require("@jujulego/jill-core");
|
|
11
13
|
|
|
12
|
-
var
|
|
14
|
+
var _ink = require("ink");
|
|
15
|
+
|
|
16
|
+
var _react = require("react");
|
|
17
|
+
|
|
18
|
+
var _command = require("../command");
|
|
19
|
+
|
|
20
|
+
var _TaskSetSpinner = require("../components/TaskSetSpinner");
|
|
21
|
+
|
|
22
|
+
var _project = require("../wrappers/project.wrapper");
|
|
13
23
|
|
|
14
24
|
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
|
|
15
25
|
function adopt(value) {
|
|
@@ -70,134 +80,99 @@ var __asyncValues = void 0 && (void 0).__asyncValues || function (o) {
|
|
|
70
80
|
};
|
|
71
81
|
|
|
72
82
|
// Command
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
83
|
+
const {
|
|
84
|
+
wrapper,
|
|
85
|
+
useArgs
|
|
86
|
+
} = (0, _project.withProject)((0, _command.command)({
|
|
87
|
+
name: 'each <script>',
|
|
88
|
+
description: 'Run script on selected workspaces',
|
|
89
|
+
builder: yargs => yargs.positional('script', {
|
|
90
|
+
type: 'string',
|
|
91
|
+
demandOption: true
|
|
92
|
+
}).option('deps-mode', {
|
|
93
|
+
choice: ['all', 'prod', 'none'],
|
|
94
|
+
default: 'all',
|
|
95
|
+
desc: 'Dependency selection mode:\n' + ' - all = dependencies AND devDependencies\n' + ' - prod = dependencies\n' + ' - none = nothing'
|
|
96
|
+
}).option('private', {
|
|
97
|
+
type: 'boolean',
|
|
98
|
+
group: 'Filters:',
|
|
99
|
+
desc: 'Print only private workspaces'
|
|
100
|
+
}).option('affected', {
|
|
101
|
+
alias: 'a',
|
|
102
|
+
type: 'string',
|
|
103
|
+
coerce: rev => rev === '' ? 'master' : rev,
|
|
104
|
+
group: 'Affected:',
|
|
105
|
+
desc: 'Print only affected workspaces towards given git revision. If no revision is given, it will check towards master.\n' + 'Replaces %name by workspace name.'
|
|
106
|
+
}).option('affected-rev-sort', {
|
|
107
|
+
type: 'string',
|
|
108
|
+
group: 'Affected:',
|
|
109
|
+
desc: 'Sort applied to git tag / git branch command'
|
|
110
|
+
}).option('affected-rev-fallback', {
|
|
111
|
+
type: 'string',
|
|
112
|
+
default: 'master',
|
|
113
|
+
group: 'Affected:',
|
|
114
|
+
desc: 'Fallback revision, used if no revision matching the given format is found'
|
|
115
|
+
})
|
|
116
|
+
})); // Component
|
|
117
|
+
|
|
118
|
+
const EachCommand = wrapper(function EachCommand() {
|
|
119
|
+
const args = useArgs();
|
|
120
|
+
const project = (0, _project.useProject)();
|
|
121
|
+
const {
|
|
122
|
+
exit
|
|
123
|
+
} = (0, _ink.useApp)(); // Refs
|
|
124
|
+
|
|
125
|
+
const tasks = (0, _react.useRef)(new _jillCore.TaskSet()); // Effects
|
|
126
|
+
|
|
127
|
+
(0, _react.useEffect)(() => void (() => __awaiter(this, void 0, void 0, function* () {
|
|
119
128
|
var e_1, _a;
|
|
120
129
|
|
|
121
|
-
var _b;
|
|
122
|
-
|
|
123
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
yield _super.run.call(this, args); // Setup pipeline
|
|
130
|
+
var _b; // Setup pipeline
|
|
125
131
|
|
|
126
|
-
const pipeline = new _jillCommon.Pipeline();
|
|
127
|
-
pipeline.add(_jillCommon.Filter.scripts([args.script]));
|
|
128
|
-
|
|
129
|
-
if (args.private !== undefined) {
|
|
130
|
-
pipeline.add(_jillCommon.Filter.privateWorkspace(args.private));
|
|
131
|
-
}
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
} // Filter
|
|
133
|
+
const pipeline = new _jillCommon.Pipeline();
|
|
134
|
+
pipeline.add(_jillCommon.Filter.scripts([args.script]));
|
|
136
135
|
|
|
136
|
+
if (args.private !== undefined) {
|
|
137
|
+
pipeline.add(_jillCommon.Filter.privateWorkspace(args.private));
|
|
138
|
+
}
|
|
137
139
|
|
|
138
|
-
|
|
140
|
+
if (args.affected !== undefined) {
|
|
141
|
+
pipeline.add(new _jillCommon.AffectedFilter(args.affected, args.affectedRevFallback, args.affectedRevSort));
|
|
142
|
+
}
|
|
139
143
|
|
|
144
|
+
try {
|
|
145
|
+
// Filter and create tasks
|
|
146
|
+
for (var _c = __asyncValues(pipeline.filter(project.workspaces())), _d; _d = yield _c.next(), !_d.done;) {
|
|
147
|
+
const wks = _d.value;
|
|
148
|
+
tasks.current.add(yield wks.run(args.script, (_b = args['--']) === null || _b === void 0 ? void 0 : _b.map(arg => arg.toString()), {
|
|
149
|
+
buildDeps: args.depsMode
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
} catch (e_1_1) {
|
|
153
|
+
e_1 = {
|
|
154
|
+
error: e_1_1
|
|
155
|
+
};
|
|
156
|
+
} finally {
|
|
140
157
|
try {
|
|
141
|
-
|
|
142
|
-
const wks = _d.value;
|
|
143
|
-
workspaces.push(wks);
|
|
144
|
-
}
|
|
145
|
-
} catch (e_1_1) {
|
|
146
|
-
e_1 = {
|
|
147
|
-
error: e_1_1
|
|
148
|
-
};
|
|
158
|
+
if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c);
|
|
149
159
|
} finally {
|
|
150
|
-
|
|
151
|
-
if (_d && !_d.done && (_a = _c.return)) yield _a.call(_c);
|
|
152
|
-
} finally {
|
|
153
|
-
if (e_1) throw e_1.error;
|
|
154
|
-
}
|
|
160
|
+
if (e_1) throw e_1.error;
|
|
155
161
|
}
|
|
162
|
+
}
|
|
156
163
|
|
|
157
|
-
|
|
158
|
-
this.spinner.fail('No workspace found !');
|
|
159
|
-
return 1;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
this.spinner.stop();
|
|
163
|
-
this.logger.verbose(`Will run ${args.script} in ${workspaces.map(wks => wks.name).join(', ')}`); // Run tasks
|
|
164
|
-
|
|
165
|
-
const set = new _jillCore.TaskSet();
|
|
166
|
-
const tasks = [];
|
|
167
|
-
|
|
168
|
-
for (const wks of workspaces) {
|
|
169
|
-
const task = yield wks.run(args.script, (_b = args['--']) === null || _b === void 0 ? void 0 : _b.map(arg => arg.toString()), {
|
|
170
|
-
buildDeps: args['deps-mode']
|
|
171
|
-
});
|
|
172
|
-
tasks.push(task);
|
|
173
|
-
set.add(task);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const tlogger = new _taskLogger.TaskLogger();
|
|
177
|
-
tlogger.on('spin-multiple', count => `Working in ${count} packages ...`);
|
|
178
|
-
tlogger.on('spin-simple', tsk => {
|
|
179
|
-
var _a, _b;
|
|
180
|
-
|
|
181
|
-
return tasks.includes(tsk) ? `Running ${args.script} in ${(_a = tsk.context.workspace) === null || _a === void 0 ? void 0 : _a.name} ...` : `Building ${(_b = tsk.context.workspace) === null || _b === void 0 ? void 0 : _b.name} ...`;
|
|
182
|
-
});
|
|
183
|
-
tlogger.on('fail', tsk => {
|
|
184
|
-
var _a, _b;
|
|
185
|
-
|
|
186
|
-
return tasks.includes(tsk) ? `${(_a = tsk.context.workspace) === null || _a === void 0 ? void 0 : _a.name} ${args.script} failed` : `Failed to build ${(_b = tsk.context.workspace) === null || _b === void 0 ? void 0 : _b.name}`;
|
|
187
|
-
});
|
|
188
|
-
tlogger.on('succeed', tsk => {
|
|
189
|
-
var _a, _b;
|
|
164
|
+
tasks.current.start(); // Result end code
|
|
190
165
|
|
|
191
|
-
|
|
192
|
-
});
|
|
193
|
-
tlogger.connect(set);
|
|
194
|
-
set.start();
|
|
195
|
-
const [result] = yield set.waitFor('finished');
|
|
196
|
-
return result.failed === 0 ? 0 : 1;
|
|
197
|
-
});
|
|
198
|
-
}
|
|
166
|
+
const [result] = yield tasks.current.waitFor('finished');
|
|
199
167
|
|
|
200
|
-
|
|
168
|
+
if (result.failed) {
|
|
169
|
+
exit(new Error('Some tasks has failed'));
|
|
170
|
+
}
|
|
171
|
+
}))(), [args]); // Render
|
|
201
172
|
|
|
173
|
+
return (0, _jsxRuntime.jsx)(_TaskSetSpinner.TaskSetSpinner, {
|
|
174
|
+
taskSet: tasks.current
|
|
175
|
+
});
|
|
176
|
+
});
|
|
202
177
|
exports.EachCommand = EachCommand;
|
|
203
178
|
//# sourceMappingURL=each.command.js.map
|