Skip to content
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

Downgrade oclif and typescript #666

Merged
merged 3 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"tmp": "^0.2.1",
"ts-node": "^10.7.0",
"tslib": "^2.3.1",
"typescript": "4.8.4"
"typescript": "4.6.4"
},
"workspaces": {
"packages": [
Expand All @@ -104,6 +104,6 @@
"resolutions": {
"@types/react": "16.14.0",
"vite": "2.9.12",
"@oclif/core": "1.16.4"
"@oclif/core": "1.9.2"
}
}
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
},
"dependencies": {
"@luckycatfactory/esbuild-graphql-loader": "3.7.0",
"@oclif/core": "1.16.4",
"@oclif/core": "1.9.2",
"@shopify/cli-kit": "3.19.0",
"@shopify/shopify-cli-extensions": "3.19.0",
"abort-controller": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-hydrogen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
]
},
"dependencies": {
"@oclif/core": "1.16.4",
"@oclif/core": "1.9.2",
"@shopify/hydrogen": "^0.26.0",
"@shopify/mini-oxygen": "^0.2.0",
"@types/prettier": "^2.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"dependencies": {
"@bugsnag/js": "^7.16.7",
"@iarna/toml": "^2.2.5",
"@oclif/core": "1.16.4",
"@oclif/core": "1.9.2",
"@types/archiver": "^5.3.1",
"abort-controller": "^3.0.0",
"archiver": "^5.3.1",
Expand Down
9 changes: 2 additions & 7 deletions packages/cli-kit/src/node/base-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ describe('applying presets', async () => {
function expectFlags(path: string, preset: keyof typeof allPresets) {
expect(testResult).toEqual({
path: resolvePath(path),
verbose: false,
someStringWithDefault: 'default stringy',
preset,
...allPresets[preset],
Expand All @@ -129,7 +128,6 @@ describe('applying presets', async () => {
// Then
expect(testResult).toEqual({
path: resolvePath(tmpDir),
verbose: false,
someStringWithDefault: 'default stringy',
})
expect(outputMock.info()).toEqual('')
Expand Down Expand Up @@ -180,7 +178,6 @@ describe('applying presets', async () => {
expect(testResult).toEqual({
path: resolvePath(subdir),
preset: 'validPreset',
verbose: false,
// no flags applied from the preset
someStringWithDefault: 'default stringy',
})
Expand Down Expand Up @@ -213,7 +210,6 @@ describe('applying presets', async () => {
path: resolvePath(tmpDir),
preset: 'nonexistentPreset',
someStringWithDefault: 'default stringy',
verbose: false,
})
})

Expand All @@ -225,7 +221,6 @@ describe('applying presets', async () => {
expect(testResult).toEqual({
path: resolvePath(tmpDir),
preset: 'validPresetWithIrrelevantFlag',
verbose: false,
...validPreset,
someStringWithDefault: 'default stringy',
})
Expand All @@ -244,7 +239,7 @@ describe('applying presets', async () => {
await MockCommand.run(['--path', tmpDir, '--preset', 'presetWithExclusiveArguments'])

// Then
expect(testError?.message).toMatch('--someBoolean=true cannot also be provided when using --someExclusiveString')
expect(testError?.message).toMatch('--someBoolean= cannot also be provided when using --someExclusiveString')
})

runTestInTmpDir('throws on negated booleans', async (tmpDir: string) => {
Expand Down Expand Up @@ -272,7 +267,7 @@ describe('applying presets', async () => {
await MockCommand.run(['--path', tmpDir, '--preset', 'validPreset', '--someExclusiveString', 'stringy'])

// Then
expect(testError?.message).toMatch('--someBoolean=true cannot also be provided when using --someExclusiveString')
expect(testError?.message).toMatch('--someBoolean= cannot also be provided when using --someExclusiveString')
},
)

Expand Down
50 changes: 20 additions & 30 deletions packages/cli-kit/src/node/base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,25 @@ abstract class BaseCommand extends Command {

protected async parse<
TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},
TGlobalFlags extends Interfaces.FlagOutput,
TArgs extends Interfaces.OutputArgs,
>(
options?: Interfaces.Input<TFlags, TGlobalFlags> | undefined,
options?: Interfaces.Input<TFlags> | undefined,
argv?: string[] | undefined,
): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {
let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)
result = await this.resultWithPreset<TFlags, TGlobalFlags, TArgs>(options, argv, result)
): Promise<Interfaces.ParserOutput<TFlags, TArgs>> {
let result = await super.parse<TFlags, TArgs>(options, argv)
result = await this.resultWithPreset<TFlags, TArgs>(options, argv, result)
await addFromParsedFlags(result.flags)
return result
}

protected async resultWithPreset<
TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},
TGlobalFlags extends Interfaces.FlagOutput,
TArgs extends Interfaces.OutputArgs,
>(
options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,
options: Interfaces.Input<TFlags> | undefined,
argv: string[] | undefined,
originalResult: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>,
): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {
originalResult: Interfaces.ParserOutput<TFlags, TArgs>,
): Promise<Interfaces.ParserOutput<TFlags, TArgs>> {
// If no preset is specified, don't modify the results
const flags = originalResult.flags as PresettableFlags
if (!flags.preset) return originalResult
Expand All @@ -65,19 +63,19 @@ abstract class BaseCommand extends Command {

// Parse using noDefaultsOptions to derive a list of flags specified as
// command-line arguments.
const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)
const noDefaultsResult = await super.parse<TFlags, TArgs>(noDefaultsOptions(options), argv)

// Add the preset's settings to argv and pass them to `super.parse`. This
// invokes oclif's validation system without breaking the oclif black box.
// Replace the original result with this one.
const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [
const result = await super.parse<TFlags, TArgs>(options, [
// Need to specify argv default because we're merging with argsFromPreset.
...(argv || this.argv),
...argsFromPreset<TFlags, TGlobalFlags, TArgs>(preset, options, noDefaultsResult),
...argsFromPreset<TFlags, TArgs>(preset, options, noDefaultsResult),
])

// Report successful application of the preset.
reportPresetApplication<TFlags, TGlobalFlags, TArgs>(noDefaultsResult.flags, result.flags, flags.preset, preset)
reportPresetApplication<TFlags, TArgs>(noDefaultsResult.flags, result.flags, flags.preset, preset)

return result
}
Expand Down Expand Up @@ -111,13 +109,9 @@ export async function addFromParsedFlags(flags: {path?: string; verbose?: boolea
* It doesn't matter if the preset flag's value was the same as the default; from
* the user's perspective, they want to know their preset was applied.
*/
function reportPresetApplication<
TFlags extends Interfaces.FlagOutput,
TGlobalFlags extends Interfaces.FlagOutput,
TArgs extends Interfaces.OutputArgs,
>(
noDefaultsFlags: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],
flagsWithPresets: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],
function reportPresetApplication<TFlags extends Interfaces.FlagOutput, TArgs extends Interfaces.OutputArgs>(
noDefaultsFlags: Interfaces.ParserOutput<TFlags, TArgs>['flags'],
flagsWithPresets: Interfaces.ParserOutput<TFlags, TArgs>['flags'],
presetName: string,
preset: JsonMap,
): void {
Expand Down Expand Up @@ -157,9 +151,9 @@ ${Object.entries(changes)
* the user actually passed on the command line.
*/

function noDefaultsOptions<TFlags extends Interfaces.FlagOutput, TGlobalFlags extends Interfaces.FlagOutput>(
options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,
): Interfaces.Input<TFlags, TGlobalFlags> | undefined {
function noDefaultsOptions<TFlags extends Interfaces.FlagOutput>(
options: Interfaces.Input<TFlags> | undefined,
): Interfaces.Input<TFlags> | undefined {
if (!options?.flags) return options
return {
...options,
Expand All @@ -177,14 +171,10 @@ function noDefaultsOptions<TFlags extends Interfaces.FlagOutput, TGlobalFlags ex
* Converts the preset's settings to arguments as though passed on the command
* line, skipping any arguments the user specified on the command line.
*/
function argsFromPreset<
TFlags extends Interfaces.FlagOutput,
TGlobalFlags extends Interfaces.FlagOutput,
TArgs extends Interfaces.OutputArgs,
>(
function argsFromPreset<TFlags extends Interfaces.FlagOutput, TArgs extends Interfaces.OutputArgs>(
preset: JsonMap,
options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,
noDefaultsResult: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>,
options: Interfaces.Input<TFlags> | undefined,
noDefaultsResult: Interfaces.ParserOutput<TFlags, TArgs>,
): string[] {
const args: string[] = []
for (const [label, value] of Object.entries(preset)) {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
]
},
"dependencies": {
"@oclif/core": "1.16.4",
"@oclif/core": "1.9.2",
"@oclif/plugin-commands": "^2.2.0",
"@oclif/plugin-help": "^5.1.14",
"@oclif/plugin-plugins": "^2.1.1",
"@oclif/plugin-help": "^5.1.12",
"@oclif/plugin-plugins": "^2.1.0",
"@shopify/cli-kit": "3.19.0",
"@shopify/plugin-ngrok": "^3.19.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
]
},
"dependencies": {
"@oclif/core": "1.16.4",
"@oclif/core": "1.9.2",
"@shopify/cli-kit": "3.19.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-hydrogen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}
},
"dependencies": {
"@oclif/core": "1.16.4",
"@oclif/core": "1.9.2",
"@shopify/cli-kit": "3.19.0",
"download": "8.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ngrok/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"type-check": "nx type-check"
},
"dependencies": {
"@oclif/core": "1.16.4",
"@oclif/core": "1.9.2",
"@shopify/cli-kit": "3.19.0",
"@shopify/ngrok": "^4.3.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
]
},
"dependencies": {
"@oclif/core": "1.16.4",
"@oclif/core": "1.9.2",
"@shopify/cli-kit": "3.19.0"
},
"devDependencies": {
Expand Down
45 changes: 25 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1700,10 +1700,10 @@
supports-color "^8.1.1"
tslib "^2"

"@oclif/core@1.16.4", "@oclif/core@^1.16.4":
version "1.16.4"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-1.16.4.tgz#fafa338ada0624d7f1adac036302b05a37cd96d0"
integrity sha512-l+xHtVMteJWeTZZ+f2yLyNjf69X0mhAH8GILXnmoAGAemXbc1DVstvloxOouarvm9xyHHhquzO1Qg5l6xa1VIw==
"@oclif/core@1.9.2", "@oclif/core@^1.19.1", "@oclif/core@^1.2.0":
version "1.9.2"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-1.9.2.tgz#19005ee1fbde16ed2b1926dfeb00e55fd7b45b4d"
integrity sha512-+qhfvDHn+tR4UN/Vk3UYIeM0Dm0XKsHrM4igJrUpJj/ZXXdaGbZEB+cMIRDZHGqBw+pcwP4+9zQFmxotMDIWcw==
dependencies:
"@oclif/linewrap" "^1.0.0"
"@oclif/screen" "^3.0.2"
Expand Down Expand Up @@ -1747,27 +1747,27 @@
"@oclif/core" "^1.2.0"
lodash "^4.17.11"

"@oclif/plugin-help@^5.1.14":
version "5.1.14"
resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-5.1.14.tgz#641e6f2c7effb4a21573d50c649af662a919bcf9"
integrity sha512-jhpD0a2bEp3YW93sQcUM3b15DH+svQqC9pMXNp1m1VyAPoskdaELgt5P/5SjmNuFwqws8scxpbYKlr2/lvvkGQ==
"@oclif/plugin-help@^5.1.12":
version "5.1.16"
resolved "https://registry.yarnpkg.com/@oclif/plugin-help/-/plugin-help-5.1.16.tgz#b55376e50007ba6b73819b11d02232288203fb70"
integrity sha512-30uy/bRUzptI4mFf6re1imTBxJJB2r9pQyZ7sbr8zn0oymLZX4dMArlMDi/LwpPqEtIN3fivXgDkjcoKO8ezGQ==
dependencies:
"@oclif/core" "^1.16.4"
"@oclif/core" "^1.19.1"

"@oclif/plugin-plugins@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@oclif/plugin-plugins/-/plugin-plugins-2.1.1.tgz#3523cc07059843cc063e250cfc4f3cb6f344e397"
integrity sha512-EUffiFH8g1N8AQrxhBe+eIxDXkx2tZ/IgTkWFfzO/ujzQt1GkXAG85PMIuau6t8FZQlJ/nSNZ1H7z7bJxAsAFA==
"@oclif/plugin-plugins@^2.1.0":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@oclif/plugin-plugins/-/plugin-plugins-2.1.5.tgz#2d7fd1a87dc47c5cc6267ac17e3f3692218348fa"
integrity sha512-wG+n81R/tMavnRKHJi2two6rski42aMkeanuBxQCFhGUCstKHu7pbiYuvgzDGCisNIiUvCVUdu9colOFS6FUmA==
dependencies:
"@oclif/color" "^1.0.1"
"@oclif/core" "^1.16.4"
"@oclif/core" "^1.19.1"
chalk "^4.1.2"
debug "^4.3.4"
fs-extra "^9.0"
http-call "^5.2.2"
load-json-file "^5.3.0"
npm-run-path "^4.0.1"
semver "^7.3.2"
semver "^7.3.8"
tslib "^2.0.0"
yarn "^1.22.18"

Expand Down Expand Up @@ -11234,7 +11234,7 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

semver@^7.3.4:
semver@^7.3.4, semver@^7.3.8:
version "7.3.8"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
Expand Down Expand Up @@ -12517,16 +12517,21 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==

typescript@4.8.4, typescript@^4.8.4:
version "4.8.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==
typescript@4.6.4:
version "4.6.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9"
integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==

typescript@^4.7.2:
version "4.8.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.2.tgz#e3b33d5ccfb5914e4eeab6699cf208adee3fd790"
integrity sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==

typescript@^4.8.4:
version "4.8.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==

typical@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4"
Expand Down