Skip to content

Commit 4ece9ed

Browse files
committed
fix(ci): feature branch name missing from toolkit artifact
Problem: Because of the `npm run restorePackageJson` step, the `--feature separate-sessions` arg is not passed to `package.ts`: npm run copyPackageJson && ts-node ../../scripts/package.ts && npm run restorePackageJson --feature separate-sessions Thus the feature branch name is not in the toolkit artifact name. For example, the feature/separate-sessions branch artifacts are: amazon-q-vscode-1.10.0-separate-sessions-g8a563a7.vsix aws-toolkit-vscode-3.11.0-g8a563a7.vsix Solution: Inline the `--restore` logic into `package.ts`. This is hacky, but should be temporary after we resolved IDE-12831 so that these hacks are no longer needed.
1 parent af96cc0 commit 4ece9ed

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

packages/toolkit/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,15 @@
6363
"webWatch": "npm run clean && npm run buildScripts && webpack --mode development --watch",
6464
"webCompile": "npm run clean && npm run buildScripts && webpack --config-name web",
6565
"webRun": "npx @vscode/test-web --open-devtools --browserOption=--disable-web-security --waitForDebugger=9222 --extensionDevelopmentPath=. .",
66-
"package": "npm run copyPackageJson && ts-node ../../scripts/package.ts && npm run restorePackageJson",
66+
"package": "npm run copyPackageJson && ts-node ../../scripts/package.ts",
6767
"install-plugin": "vsce package --ignoreFile '../.vscodeignore.packages' -o aws-toolkit-vscode-test.vsix && code --install-extension aws-toolkit-vscode-test.vsix",
6868
"format": "prettier --ignore-path ../../.prettierignore --check src scripts",
6969
"formatfix": "prettier --ignore-path ../../.prettierignore --write src scripts",
7070
"lint": "echo 'Nothing to lint yet!'",
7171
"createRelease": "ts-node ../../scripts/createRelease.ts",
7272
"newChange": "ts-node ../../scripts/newChange.ts",
7373
"watch": "npm run clean && npm run buildScripts && tsc -watch -p ./",
74-
"copyPackageJson": "ts-node ./scripts/build/handlePackageJson",
75-
"restorePackageJson": "ts-node ./scripts/build/handlePackageJson --restore"
74+
"copyPackageJson": "ts-node ./scripts/build/handlePackageJson"
7675
},
7776
"devDependencies": {},
7877
"dependencies": {

packages/toolkit/scripts/build/handlePackageJson.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@
1010
* To avoid having duplicate code, we copy the necessary fields from the core library to the separate toolkit
1111
* extension when required (e.g. debugging, packaging).
1212
*
13-
* TODO: Find a better way to do this, hopefully remove the need for this in the core library.
13+
* TODO: IDE-12831 tracks work to elminate this script.
1414
*
1515
* Args:
16-
* --restore : reverts the package json changes to the original state
16+
* --restore: (XXX: this mode was inlined into the package.ts script.)
1717
* --development: performs actions that should only be done during development and not production
1818
*/
1919

2020
import * as fs from 'fs-extra'
2121

2222
function main() {
2323
const args = process.argv.slice(2)
24-
const restoreMode = args.includes('--restore')
24+
// XXX: --restore mode was inlined into the package.ts script.
25+
const restoreMode = false
2526

2627
if (args.includes('--development')) {
2728
/** When we actually package the extension the null extension does not occur, so we will skip this hack */
@@ -33,12 +34,14 @@ function main() {
3334
const coreLibPackageJsonFile = '../core/package.json'
3435

3536
if (restoreMode) {
36-
try {
37-
fs.copyFileSync(backupJsonFile, packageJsonFile)
38-
fs.unlinkSync(backupJsonFile)
39-
} catch (err) {
40-
console.log(`Could not restore package.json. Error: ${err}`)
41-
}
37+
// XXX: --restore mode was inlined into the package.ts script.
38+
// TODO: remove this after IDE-12831 is resolved.
39+
// try {
40+
// fs.copyFileSync(backupJsonFile, packageJsonFile)
41+
// fs.unlinkSync(backupJsonFile)
42+
// } catch (err) {
43+
// console.log(`Could not restore package.json. Error: ${err}`)
44+
// }
4245
} else {
4346
fs.copyFileSync(packageJsonFile, backupJsonFile)
4447
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile, { encoding: 'utf-8' }))

scripts/package.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ function isBeta(): boolean {
8585
}
8686
}
8787

88+
/**
89+
* Restores package.json after `scripts/build/handlePackageJson.ts` overwrote it.
90+
*
91+
* TODO: remove this after IDE-12831 is resolved.
92+
*/
93+
function restorePackageJson() {
94+
const packageJsonFile = './package.json'
95+
const backupJsonFile = `${packageJsonFile}.handlePackageJson.bk`
96+
97+
if (fs.existsSync(backupJsonFile)) {
98+
fs.copyFileSync(backupJsonFile, packageJsonFile)
99+
fs.unlinkSync(backupJsonFile)
100+
console.log(`package.ts: restored package.json from ${backupJsonFile}`)
101+
}
102+
}
103+
88104
/**
89105
* Gets a suffix to append to the version-string, or empty for release builds.
90106
*
@@ -177,6 +193,7 @@ function main() {
177193
fs.copyFileSync(backupWebpackConfigFile, webpackConfigJsFile)
178194
fs.unlinkSync(backupWebpackConfigFile)
179195
}
196+
restorePackageJson()
180197
}
181198
}
182199

0 commit comments

Comments
 (0)