-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI bug: Interactive mode -> Unpacker -> Input file path -> 'Input does not exist' when using prefix/**/*.js
glob pattern
#81
Comments
prefix/**/*.js
glob patternprefix/**/*.js
glob pattern
Looking at the code, this seems to be implemented here: wakaru/packages/cli/src/cli.ts Lines 203 to 218 in 3758f48
It seems to be using the
I'm not sure if the CLI is designed to be able to be passed a folder without a glob, but if so, then these checks should accept a folder as the path. For checking globs, I think maybe a function like It seems
|
The CLI calls wakaru/packages/cli/src/cli.ts Lines 275 to 278 in 3758f48
wakaru/packages/cli/src/unpacker.ts Lines 15 to 25 in 3758f48
That said, if we wanted to enhance things to be able to specify a folder path (that would then apply a default glob, eg.
|
I think currently, the wakaru/packages/cli/src/cli.ts Lines 211 to 214 in 3758f48
At least, depending on how that glob is defined I suppose: wakaru/packages/cli/src/path.ts Lines 6 to 12 in 3758f48
|
This one is on my todo list. Can open in another one. |
The path validation in unpacker is not correct because it forgot to calculate the glob. And this is path validation in unminify: wakaru/packages/cli/src/cli.ts Lines 314 to 316 in 3758f48
|
My expectation on the path input would be only "file(s)" or "glob to files". I'm also not sure about the use of a passing folder... If we don't change the design, we can improve the error message to be |
@pionxzh Done:
@pionxzh I don't have strong feelings either way. The first way I tried to do it was just passing the input folder path, but it's not much extra effort for me to be explicit and use a glob. If a folder path on it's own isn't allowed, then I definitely think the improved error message is a good idea. For simplicity sake/reducing the number of options, I would probably suggest just forcing the user to use a glob + showing the improved error message. |
Whichever way is chosen though, the validation should probably be shared between passing args via CLI flags, versus using interactive mode, as currently it looks like it (at least somewhat) works to pass a folder as the input path via CLI args: ⇒ npx @wakaru/cli unpacker unpacked --unpacker-output stage2-unpacked --perf
┌ Wakaru CLI v0.0.2
│
└ Selected features: Unpacker
┌ Unpacker
│
◇ Unpacking...
SyntaxError: Leading decorators must be attached to a class declaration. (1:5)
at constructor (/Users/devalias/.npm/_npx/adacf4dfcf214674/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:18018:23)
at FlowParserMixin.raise (/Users/devalias/.npm/_npx/adacf4dfcf214674/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:20914:23)
at FlowParserMixin.parseDecorators (/Users/devalias/.npm/_npx/adacf4dfcf214674/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:30573:22)
at FlowParserMixin.parseStatementLike (/Users/devalias/.npm/_npx/adacf4dfcf214674/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:30370:29)
at FlowParserMixin.parseStatementLike (/Users/devalias/.npm/_npx/adacf4dfcf214674/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:22799:28)
at FlowParserMixin.parseModuleItem (/Users/devalias/.npm/_npx/adacf4dfcf214674/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:30349:21)
at FlowParserMixin.parseBlockOrModuleBlockBody (/Users/devalias/.npm/_npx/adacf4dfcf214674/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:30976:40)
at FlowParserMixin.parseBlockBody (/Users/devalias/.npm/_npx/adacf4dfcf214674/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:30969:14)
at FlowParserMixin.parseProgram (/Users/devalias/.npm/_npx/adacf4dfcf214674/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:30248:14)
at FlowParserMixin.parseTopLevel (/Users/devalias/.npm/_npx/adacf4dfcf214674/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:30238:29) {
code: 'BABEL_PARSER_SYNTAX_ERROR',
reasonCode: 'UnexpectedLeadingDecorator',
loc: Position { line: 1, column: 5, index: 5 },
pos: 5
} Technically even if the user is forced to use a glob, they could write a glob that only matches a folder, so we would also need to make sure that the expanded glob path is filtered down to the list of files (assuming that isn't already being done). |
Trying the new CLI in interactive mode, it seems to have issues when I give it an input file path like
unpacked/**/*.js
, even though that path definitely exists (running from the root dir of this checked out repo (Ref))If I change the input path to something like
unpacked/
, then the error message changes toInput is not a file
.While I haven't looked too deeply into it, I think there might currently be a check to ensure that the provided input is a file; but that would then break the ability to import folders and globs.
While it's OOS of this issue, I also noticed that it's not possible to tab complete files/paths while using the interactive mode. That may be by design, but it would probably make it more user friendly. I can open this as a separate issue if desired.
Edit: See:
The text was updated successfully, but these errors were encountered: