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

feat: no lockfiles in tarballs by default #1385

Merged
merged 4 commits into from
Apr 25, 2024
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
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ jobs:
with:
node-version: ${{ matrix.node_version }}
cache: yarn
# oclif pack tarballs needs a git commit to work, so the tests need to be able to run `git commit` with the correct user info
- uses: salesforcecli/github-workflows/.github/actions/getGithubUserInfo@main
id: github-user-info
with:
SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
- uses: salesforcecli/github-workflows/.github/actions/gitConfig@main
with:
username: ${{ steps.github-user-info.outputs.username }}
email: ${{ steps.github-user-info.outputs.email }}
- if: matrix.package_manager == 'pnpm'
run: 'npm install -g pnpm'
- uses: salesforcecli/github-workflows/.github/actions/yarnInstallWithRetries@main
Expand Down
1 change: 1 addition & 0 deletions src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export default class Generate extends GeneratorCommand<typeof Generate> {
}

await exec(`${packageManager} install`, {cwd: location, silent: false})
await exec(`${packageManager} run build`, {cwd: location, silent: false})
await exec(`${join(location, 'node_modules', '.bin', 'oclif')} readme`, {
cwd: location,
// When testing this command in development, you get noisy compilation errors as a result of running
Expand Down
10 changes: 9 additions & 1 deletion src/commands/pack/deb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ export default class PackDeb extends Command {
'For more details see the `-Zcompress-type` section at https://man7.org/linux/man-pages/man1/dpkg-deb.1.html',
summary: 'Override the default compression used by dpkg-deb.',
}),
'prune-lockfiles': Flags.boolean({description: 'remove lockfiles in the tarball.', exclusive: ['tarball']}),
root: Flags.string({char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true}),
tarball: Flags.string({
char: 't',
description: 'Optionally specify a path to a tarball already generated by NPM.',
exclusive: ['prune-lockfiles'],
required: false,
}),
}
Expand All @@ -79,7 +81,13 @@ export default class PackDeb extends Command {
const {flags} = await this.parse(PackDeb)
const buildConfig = await Tarballs.buildConfig(flags.root)
const {config} = buildConfig
await Tarballs.build(buildConfig, {pack: false, parallel: true, platform: 'linux', tarball: flags.tarball})
await Tarballs.build(buildConfig, {
pack: false,
parallel: true,
platform: 'linux',
pruneLockfiles: flags['prune-lockfiles'],
tarball: flags.tarball,
})
const dist = buildConfig.dist('deb')
await fs.emptyDir(dist)
const build = async (arch: Interfaces.ArchTypes) => {
Expand Down
10 changes: 9 additions & 1 deletion src/commands/pack/macos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export default class PackMacos extends Command {
the CLI should already exist in a directory named after the CLI that is the root of the tarball produced by "oclif pack:tarballs"`,
hidden: true,
}),
'prune-lockfiles': Flags.boolean({description: 'remove lockfiles in the tarball.', exclusive: ['tarball']}),
root: Flags.string({
char: 'r',
default: '.',
Expand All @@ -156,6 +157,7 @@ the CLI should already exist in a directory named after the CLI that is the root
tarball: Flags.string({
char: 't',
description: 'Optionally specify a path to a tarball already generated by NPM.',
exclusive: ['prune-lockfiles'],
required: false,
}),
targets: Flags.string({
Expand All @@ -175,7 +177,13 @@ the CLI should already exist in a directory named after the CLI that is the root
if (!c.macos.identifier) this.error('package.json must have oclif.macos.identifier set')
const macos = c.macos
const packageIdentifier = macos.identifier
await Tarballs.build(buildConfig, {pack: false, parallel: true, platform: 'darwin', tarball: flags.tarball})
await Tarballs.build(buildConfig, {
pack: false,
parallel: true,
platform: 'darwin',
pruneLockfiles: flags['prune-lockfiles'],
tarball: flags.tarball,
})
const scriptsDir = path.join(buildConfig.tmp, 'macos/scripts')
await fs.emptyDir(buildConfig.dist('macos'))
const noBundleConfigurationPath = path.join(buildConfig.tmp, 'macos', 'no-bundle.plist')
Expand Down
2 changes: 2 additions & 0 deletions src/commands/pack/tarballs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Add a pretarball script to your package.json if you need to run any scripts befo

static flags = {
parallel: Flags.boolean({description: 'Build tarballs in parallel.'}),
'prune-lockfiles': Flags.boolean({description: 'remove lockfiles in the tarball.'}),
root: Flags.string({char: 'r', default: '.', description: 'Path to oclif CLI root.', required: true}),
tarball: Flags.string({
char: 'l',
Expand All @@ -31,6 +32,7 @@ Add a pretarball script to your package.json if you need to run any scripts befo

await Tarballs.build(buildConfig, {
parallel: flags.parallel,
pruneLockfiles: flags['prune-lockfiles'],
tarball: flags.tarball,
})
}
Expand Down
10 changes: 9 additions & 1 deletion src/commands/pack/win.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ the CLI should already exist in a directory named after the CLI that is the root

summary: `Set to "checked" or "unchecked" to set the default value for the checkbox. Set to "hidden" to hide the option (will let defender do its thing).`,
}),
'prune-lockfiles': Flags.boolean({description: 'remove lockfiles in the tarball.', exclusive: ['tarball']}),
root: Flags.string({
char: 'r',
default: '.',
Expand All @@ -254,6 +255,7 @@ the CLI should already exist in a directory named after the CLI that is the root
tarball: Flags.string({
char: 't',
description: 'Optionally specify a path to a tarball already generated by NPM.',
exclusive: ['prune-lockfiles'],
required: false,
}),
targets: Flags.string({
Expand All @@ -272,7 +274,13 @@ the CLI should already exist in a directory named after the CLI that is the root
const nsisCustomization = config.nsisCustomization ? readFileSync(config.nsisCustomization, 'utf8') : ''
const arches = buildConfig.targets.filter((t) => t.platform === 'win32').map((t) => t.arch)

await Tarballs.build(buildConfig, {pack: false, parallel: true, platform: 'win32', tarball: flags.tarball})
await Tarballs.build(buildConfig, {
pack: false,
parallel: true,
platform: 'win32',
pruneLockfiles: flags['prune-lockfiles'],
tarball: flags.tarball,
})

await Promise.all(
arches.map(async (arch) => {
Expand Down