-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: erasableSyntaxOnly #15719
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
feat: erasableSyntaxOnly #15719
Changes from all commits
13ccceb
abd0333
b5dfed8
d0f9e31
826877e
06829fa
75f2a86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -206,7 +206,7 @@ export async function add(names: string[], { flags }: AddOptions) { | |
| } | ||
|
|
||
| switch (installResult) { | ||
| case UpdateResult.updated: { | ||
| case 'updated': { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't particularly care, but why did this need to be updated, does the setting care about this?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (hasCloudflareIntegration) { | ||
| const wranglerConfigURL = new URL('./wrangler.jsonc', configURL); | ||
| if (!existsSync(wranglerConfigURL)) { | ||
|
|
@@ -371,7 +371,7 @@ export async function add(names: string[], { flags }: AddOptions) { | |
| } | ||
| break; | ||
| } | ||
| case UpdateResult.cancelled: { | ||
| case 'cancelled': { | ||
| logger.info( | ||
| 'SKIP_FORMAT', | ||
| msg.cancelled( | ||
|
|
@@ -381,10 +381,10 @@ export async function add(names: string[], { flags }: AddOptions) { | |
| ); | ||
| break; | ||
| } | ||
| case UpdateResult.failure: { | ||
| case 'failure': { | ||
| throw createPrettyError(new Error(`Unable to install dependencies`)); | ||
| } | ||
| case UpdateResult.none: | ||
| case 'none': | ||
| break; | ||
| } | ||
|
|
||
|
|
@@ -448,14 +448,14 @@ export async function add(names: string[], { flags }: AddOptions) { | |
| } | ||
|
|
||
| switch (configResult) { | ||
| case UpdateResult.cancelled: { | ||
| case 'cancelled': { | ||
| logger.info( | ||
| 'SKIP_FORMAT', | ||
| msg.cancelled(`Your configuration has ${bold('NOT')} been updated.`), | ||
| ); | ||
| break; | ||
| } | ||
| case UpdateResult.none: { | ||
| case 'none': { | ||
| const data = await getPackageJson(); | ||
| if (data) { | ||
| const { dependencies = {}, devDependencies = {} } = data; | ||
|
|
@@ -473,9 +473,9 @@ export async function add(names: string[], { flags }: AddOptions) { | |
| break; | ||
| } | ||
| // NOTE: failure shouldn't happen in practice because `updateAstroConfig` doesn't return that. | ||
| // Pipe this to the same handling as `UpdateResult.updated` for now. | ||
| case UpdateResult.failure: | ||
| case UpdateResult.updated: | ||
| // Pipe this to the same handling as `'updated'` for now. | ||
| case 'failure': | ||
| case 'updated': | ||
| case undefined: { | ||
| const list = integrations | ||
| .map((integration) => ` - ${integration.integrationName}`) | ||
|
|
@@ -513,22 +513,22 @@ export async function add(names: string[], { flags }: AddOptions) { | |
| }); | ||
|
|
||
| switch (updateTSConfigResult) { | ||
| case UpdateResult.none: { | ||
| case 'none': { | ||
| break; | ||
| } | ||
| case UpdateResult.cancelled: { | ||
| case 'cancelled': { | ||
| logger.info( | ||
| 'SKIP_FORMAT', | ||
| msg.cancelled(`Your TypeScript configuration has ${bold('NOT')} been updated.`), | ||
| ); | ||
| break; | ||
| } | ||
| case UpdateResult.failure: { | ||
| case 'failure': { | ||
| throw new Error( | ||
| `Unknown error parsing tsconfig.json or jsconfig.json. Could not update TypeScript settings.`, | ||
| ); | ||
| } | ||
| case UpdateResult.updated: | ||
| case 'updated': | ||
| logger.info('SKIP_FORMAT', msg.success(`Successfully updated tsconfig`)); | ||
| } | ||
| } | ||
|
|
@@ -652,12 +652,7 @@ function setAdapter(mod: ProxifiedModule<any>, adapter: IntegrationInfo, exportN | |
| } | ||
| } | ||
|
|
||
| const enum UpdateResult { | ||
| none, | ||
| updated, | ||
| cancelled, | ||
| failure, | ||
| } | ||
| type UpdateResult = 'none' | 'updated' | 'cancelled' | 'failure'; | ||
|
|
||
| async function updateAstroConfig({ | ||
| configURL, | ||
|
|
@@ -682,13 +677,13 @@ async function updateAstroConfig({ | |
| }).code; | ||
|
|
||
| if (input === output) { | ||
| return UpdateResult.none; | ||
| return 'none'; | ||
| } | ||
|
|
||
| const diff = getDiffContent(input, output); | ||
|
|
||
| if (!diff) { | ||
| return UpdateResult.none; | ||
| return 'none'; | ||
| } | ||
|
|
||
| logger.info( | ||
|
|
@@ -716,9 +711,9 @@ async function updateAstroConfig({ | |
| if (await askToContinue({ flags, logger })) { | ||
| await fs.writeFile(fileURLToPath(configURL), output, { encoding: 'utf-8' }); | ||
| logger.debug('add', `Updated astro config`); | ||
| return UpdateResult.updated; | ||
| return 'updated'; | ||
| } else { | ||
| return UpdateResult.cancelled; | ||
| return 'cancelled'; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -736,7 +731,7 @@ async function updatePackageJsonOverrides({ | |
| const pkgURL = new URL('./package.json', configURL); | ||
| if (!existsSync(pkgURL)) { | ||
| logger.debug('add', 'No package.json found, skipping overrides update'); | ||
| return UpdateResult.none; | ||
| return 'none'; | ||
| } | ||
|
|
||
| const pkgPath = fileURLToPath(pkgURL); | ||
|
|
@@ -753,14 +748,14 @@ async function updatePackageJsonOverrides({ | |
| } | ||
|
|
||
| if (!hasChanges) { | ||
| return UpdateResult.none; | ||
| return 'none'; | ||
| } | ||
|
|
||
| const output = JSON.stringify(pkgJson, null, 2); | ||
| const diff = getDiffContent(input, output); | ||
|
|
||
| if (!diff) { | ||
| return UpdateResult.none; | ||
| return 'none'; | ||
| } | ||
|
|
||
| logger.info( | ||
|
|
@@ -777,9 +772,9 @@ async function updatePackageJsonOverrides({ | |
| if (await askToContinue({ flags, logger })) { | ||
| await fs.writeFile(pkgPath, output, { encoding: 'utf-8' }); | ||
| logger.debug('add', 'Updated package.json overrides'); | ||
| return UpdateResult.updated; | ||
| return 'updated'; | ||
| } else { | ||
| return UpdateResult.cancelled; | ||
| return 'cancelled'; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -797,7 +792,7 @@ async function updatePackageJsonScripts({ | |
| const pkgURL = new URL('./package.json', configURL); | ||
| if (!existsSync(pkgURL)) { | ||
| logger.debug('add', 'No package.json found, skipping scripts update'); | ||
| return UpdateResult.none; | ||
| return 'none'; | ||
| } | ||
|
|
||
| const pkgPath = fileURLToPath(pkgURL); | ||
|
|
@@ -814,14 +809,14 @@ async function updatePackageJsonScripts({ | |
| } | ||
|
|
||
| if (!hasChanges) { | ||
| return UpdateResult.none; | ||
| return 'none'; | ||
| } | ||
|
|
||
| const output = JSON.stringify(pkgJson, null, 2); | ||
| const diff = getDiffContent(input, output); | ||
|
|
||
| if (!diff) { | ||
| return UpdateResult.none; | ||
| return 'none'; | ||
| } | ||
|
|
||
| logger.info( | ||
|
|
@@ -838,9 +833,9 @@ async function updatePackageJsonScripts({ | |
| if (await askToContinue({ flags, logger })) { | ||
| await fs.writeFile(pkgPath, output, { encoding: 'utf-8' }); | ||
| logger.debug('add', 'Updated package.json scripts'); | ||
| return UpdateResult.updated; | ||
| return 'updated'; | ||
| } else { | ||
| return UpdateResult.cancelled; | ||
| return 'cancelled'; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -903,7 +898,7 @@ async function tryToInstallIntegrations({ | |
| strategies: ['install-metadata', 'lockfile', 'packageManager-field'], | ||
| }); | ||
| logger.debug('add', `package manager: "${packageManager?.name}"`); | ||
| if (!packageManager) return UpdateResult.none; | ||
| if (!packageManager) return 'none'; | ||
|
|
||
| const inheritedFlags = Object.entries(flags) | ||
| .map(([flag]) => { | ||
|
|
@@ -917,7 +912,7 @@ async function tryToInstallIntegrations({ | |
| .flat() as string[]; | ||
|
|
||
| const installCommand = resolveCommand(packageManager?.agent ?? 'npm', 'add', inheritedFlags); | ||
| if (!installCommand) return UpdateResult.none; | ||
| if (!installCommand) return 'none'; | ||
|
|
||
| const installSpecifiers = await convertIntegrationsToInstallSpecifiers(integrations).then( | ||
| (specifiers) => | ||
|
|
@@ -951,16 +946,16 @@ async function tryToInstallIntegrations({ | |
| }, | ||
| }); | ||
| spinner.stop('Dependencies installed.'); | ||
| return UpdateResult.updated; | ||
| return 'updated'; | ||
| } catch (err: any) { | ||
| spinner.error('Error installing dependencies.'); | ||
| logger.debug('add', 'Error installing dependencies', err); | ||
| // NOTE: `err.stdout` can be an empty string, so log the full error instead for a more helpful log | ||
| console.error('\n', err.stdout || err.message, '\n'); | ||
| return UpdateResult.failure; | ||
| return 'failure'; | ||
| } | ||
| } else { | ||
| return UpdateResult.cancelled; | ||
| return 'cancelled'; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1100,14 +1095,14 @@ async function updateTSConfig( | |
| ); | ||
|
|
||
| if (!firstIntegrationWithTSSettings && includesToAppend.length === 0) { | ||
| return UpdateResult.none; | ||
| return 'none'; | ||
| } | ||
|
|
||
| let inputConfig = await loadTSConfig(cwd); | ||
| let inputConfigText = ''; | ||
|
|
||
| if (inputConfig === 'invalid-config' || inputConfig === 'unknown-error') { | ||
| return UpdateResult.failure; | ||
| return 'failure'; | ||
| } else if (inputConfig === 'missing-config') { | ||
| logger.debug('add', "Couldn't find tsconfig.json or jsconfig.json, generating one"); | ||
| inputConfig = { | ||
|
|
@@ -1136,7 +1131,7 @@ async function updateTSConfig( | |
| const diff = getDiffContent(inputConfigText, output); | ||
|
|
||
| if (!diff) { | ||
| return UpdateResult.none; | ||
| return 'none'; | ||
| } | ||
|
|
||
| logger.info( | ||
|
|
@@ -1181,9 +1176,9 @@ async function updateTSConfig( | |
| encoding: 'utf-8', | ||
| }); | ||
| logger.debug('add', `Updated ${configFileName} file`); | ||
| return UpdateResult.updated; | ||
| return 'updated'; | ||
| } else { | ||
| return UpdateResult.cancelled; | ||
| return 'cancelled'; | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add to the README in that vendor folder that you did those changes? It helps when we upgrade image-size from upstream.