-
Notifications
You must be signed in to change notification settings - Fork 76
feat: record CLI version in manifest package #184
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
Changes from 6 commits
ca3acf4
001385b
34c5b78
4bda3d6
722830b
9de66a9
0f587a4
6ce4429
9fdecb5
6276a49
7139cda
006785d
bbc36e9
fb1a1dd
a556593
df00209
6e4ace3
9214af2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { AdcPublishing } from './projenrc/adc-publishing'; | |||||
| import { BundleCli } from './projenrc/bundle'; | ||||||
| import { CodeCovWorkflow } from './projenrc/codecov'; | ||||||
| import { ESLINT_RULES } from './projenrc/eslint'; | ||||||
| import { InsertTaskStep } from './projenrc/insert-task-step'; | ||||||
| import { IssueLabeler } from './projenrc/issue-labeler'; | ||||||
| import { JsiiBuild } from './projenrc/jsii'; | ||||||
| import { RecordPublishingTimestamp } from './projenrc/record-publishing-timestamp'; | ||||||
|
|
@@ -374,11 +375,24 @@ new JsiiBuild(cloudAssemblySchema, { | |||||
| (() => { | ||||||
| cloudAssemblySchema.preCompileTask.exec('tsx projenrc/update.ts'); | ||||||
|
|
||||||
| // This file will be generated at release time. It needs to be gitignored or it will | ||||||
| // fail projen's "no tamper" check, which means it must also be generated every build time. | ||||||
| cloudAssemblySchema.preCompileTask.exec('[[ -f cli-version.json ]] || echo \'{ "version": "" }\' > cli-version.json'); | ||||||
| cloudAssemblySchema.gitignore.addPatterns('cli-version.json'); | ||||||
|
|
||||||
| cloudAssemblySchema.addPackageIgnore('*.ts'); | ||||||
| cloudAssemblySchema.addPackageIgnore('!*.d.ts'); | ||||||
| cloudAssemblySchema.addPackageIgnore('** /scripts'); | ||||||
| })(); | ||||||
|
|
||||||
| new InsertTaskStep(repoProject, { | ||||||
| taskName: 'release', | ||||||
| insertSteps: [ | ||||||
| { exec: 'ts-node projenrc/copy-cli-version-to-assembly.task.ts' }, | ||||||
| ], | ||||||
| beforeExec: 'yarn workspaces run build', | ||||||
|
||||||
| beforeExec: 'yarn workspaces run build', | |
| afterExec: 'yarn workspaces run bump', |
Since the bump task is our "dependency" here.
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 had that first but I find a "before" much more natural for an "insert" operation.
Also, yes it has to be after bump, but it also equally has to be before build, so both make sense.
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 had that first but I find a "before" much more natural for an "insert" operation.
hh so call it AppendTaskStep :)
Its fine. just a personal preference.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||
| import { promises as fs } from 'fs'; | ||||||
|
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. just FYI, not sure which is better
Suggested change
|
||||||
|
|
||||||
| /** | ||||||
| * Copy the version from the CLI into the `@aws-cdk/cloud-assembly-schema` package at release time. | ||||||
| */ | ||||||
| async function main() { | ||||||
| const cliVersion = JSON.parse(await fs.readFile('packages/aws-cdk/package.json', 'utf8')).version; | ||||||
|
|
||||||
| if (cliVersion !== '0.0.0') { | ||||||
| await fs.writeFile('packages/@aws-cdk/cloud-assembly-schema/cli-version.json', JSON.stringify({ version: cliVersion }), 'utf8'); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| main().catch(e => { | ||||||
| // this is effectively a mini-cli | ||||||
| // eslint-disable-next-line no-console | ||||||
| console.error(e); | ||||||
| process.exitCode = 1; | ||||||
| }); | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { Component, Project, TaskStep } from 'projen'; | ||
|
|
||
| export interface InsertTaskStepProps { | ||
| readonly taskName: string; | ||
| readonly insertSteps: TaskStep[]; | ||
| readonly beforeExec: string; | ||
| } | ||
|
|
||
| export class InsertTaskStep extends Component { | ||
| constructor(project: Project, private props: InsertTaskStepProps) { | ||
| super(project); | ||
| } | ||
|
|
||
| preSynthesize() { | ||
| const task = this.project.tasks.tryFind(this.props.taskName); | ||
| if (!task) { | ||
| throw new Error(`Did not find task ${this.props.taskName}`); | ||
| } | ||
|
|
||
| // Find the bump task, and do the CLI version copy straight after | ||
| const bumpIx = task.steps.findIndex(s => s.exec === this.props.beforeExec); | ||
| if (bumpIx === -1) { | ||
| throw new Error(`Did not find step: ${this.props.beforeExec}`); | ||
| } | ||
rix0rrr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Accessing internals like a dirty boi | ||
| (task as any)._steps.splice(bumpIx, 0, ...this.props.insertSteps); | ||
| } | ||
| } | ||
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 we not call the same
copy-cli-version-to-assembly.task.tsscript and have it create the empty file in case the version is 0.0.0? Just trying to minimize bash.