-
Notifications
You must be signed in to change notification settings - Fork 25
feat!: ESM + Node 18 #643
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!: ESM + Node 18 #643
Conversation
BREAKING CHANGES: node 18 minimum, ESM exports
|
This issue has been linked to a new work item: W-14259714 |
| "@oclif/core": "^2.11.8", | ||
| "chalk": "^4", | ||
| "@oclif/core": "^3.0.3", | ||
| "chalk": "^5", |
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.
any interesting learnings from the chalk/inquirer changes?
src/hooks/init.ts
Outdated
| const clientRoot = this.config.scopedEnvVar('OCLIF_CLIENT_HOME') || path.join(this.config.dataDir, 'client') | ||
|
|
||
| const {config, error: throwError} = this | ||
| const binPath = config.binPath || config.bin |
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 this go into the eslint rules.
| const binPath = config.binPath || config.bin | |
| const binPath = config.binPath ?? config.bin |
src/hooks/init.ts
Outdated
| } catch (error: any) { | ||
| if (error.code !== 'ENOENT') ux.error(error.stack) | ||
| if (error.code !== 'ENOENT') throwError(error.stack) | ||
| if ((global as any).testing) return false |
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.
where's the global and how is it being set? And is there a cleaner way to do this?
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.
I'll just remove it - I'm assuming it was added at some point for testing but I don't see anything setting it anymore
| const debug = require('debug')('oclif-update') | ||
| import {touch} from './util.js' | ||
| const debug = makeDebug('oclif-update') | ||
| import crypto from 'node:crypto' |
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.
here's an example of a great place to defer via dynamic imports so that we only load crypto when it's needed (in extract when there is a sha
src/update.ts
Outdated
| constructor(private config: Config) { | ||
| this.clientRoot = config.scopedEnvVar('OCLIF_CLIENT_HOME') || path.join(config.dataDir, 'client') | ||
| this.clientBin = path.join(this.clientRoot, 'bin', config.windows ? `${config.bin}.cmd` : config.bin) | ||
| this.clientRoot = config.scopedEnvVar('OCLIF_CLIENT_HOME') || join(config.dataDir, 'client') |
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.
| this.clientRoot = config.scopedEnvVar('OCLIF_CLIENT_HOME') || join(config.dataDir, 'client') | |
| this.clientRoot = config.scopedEnvVar('OCLIF_CLIENT_HOME') ?? join(config.dataDir, 'client') |
src/update.ts
Outdated
| if (typeof body === 'string') { | ||
| return JSON.parse(body) | ||
| } | ||
|
|
||
| return body |
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.
| if (typeof body === 'string') { | |
| return JSON.parse(body) | |
| } | |
| return body | |
| return typeof body === 'string' ? JSON.parse(body) : body |
| throw error | ||
| } | ||
| if (windows) { | ||
| const body = `@echo off |
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.
tidyness: put the shell scripts in separate files that export the value, and then import that?
test/integration/sf.integration.ts
Outdated
| let stableVersion: string | ||
| let sf: string | ||
|
|
||
| const versionToUpdateTo = '2.12.7-esm.0' |
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.
we'll have to be careful to keep this around forever?
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.
I'll update it to always grab the version just before the current nightly, which will likely always exist
test/integration/sf.integration.ts
Outdated
| const tarball = | ||
| process.platform === 'win32' | ||
| ? `https://developer.salesforce.com/media/salesforce-cli/sf/channels/${channel}/sf-win32-x64.tar.gz` | ||
| : `https://developer.salesforce.com/media/salesforce-cli/sf/channels/${channel}/sf-linux-x64.tar.gz` |
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.
| const tarball = | |
| process.platform === 'win32' | |
| ? `https://developer.salesforce.com/media/salesforce-cli/sf/channels/${channel}/sf-win32-x64.tar.gz` | |
| : `https://developer.salesforce.com/media/salesforce-cli/sf/channels/${channel}/sf-linux-x64.tar.gz` | |
| const platform = process.platform === 'win32' ? 'win32' : 'linux' | |
| const tarball = `https://developer.salesforce.com/media/salesforce-cli/sf/channels/${channel}/sf-${platform}-x64.tar.gz` |
test/integration/sf.integration.ts
Outdated
| console.log('Success!') | ||
|
|
||
| console.log('Linking plugin-update...') | ||
| // Running `plugins link` is very slow on github-action's windows runners. Writing this file |
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.
will you change this since oclif/plugin-plugins#679 merged?
|
QA notes: using @salesforce/cli/2.13.6 darwin-x64 node-v18.15.0 which is ESM, plus this plugin via ❌ every command warns about the linked plugin. Seems fine, unless you run a command with › Warning: @oclif/plugin-update is a linked ESM module and cannot be auto-transpiled. Existing compiled source will
› be used instead.✅
❌ ✅ release notes happen as expected ❌ now the user can't update back across the line to the esm version (because the update command isn't available) got back to a good state by uninstalling the linked plugin. |
Confirmed that warning goes to stderr: |
|
since linked plugins are sketchy, QA round 2 will use an installed qa release `3.2.4-qa.0
downgrade a long way via --interactive the old ✅ looks great. 🚢 |
@W-14259714@
Closes #610