Skip to content

Commit 6dccc64

Browse files
committed
build: cross-platform "packageAlpha" task
Use typescript instead of shell so that the task runs on Windows.
1 parent 6718ae9 commit 6dccc64

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

build-scripts/packageAlpha.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*!
2+
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
//
7+
// Creates an artifact that can be given to users for testing alpha builds:
8+
//
9+
// aws-toolkit-vscode-1.99.0-SNAPSHOT.vsix
10+
//
11+
// The script works like this:
12+
// 1. temporarily change `version` in package.json
13+
// 2. invoke `vsce package`
14+
// 3. restore the original package.json
15+
//
16+
17+
import * as child_process from 'child_process'
18+
import * as fs from 'fs-extra'
19+
20+
const packageJsonFile = './package.json'
21+
// Create a backup so that we can restore the original later.
22+
fs.copyFileSync(packageJsonFile, `${packageJsonFile}.bk`)
23+
24+
const packageJson = JSON.parse(fs.readFileSync('./package.json', { encoding: 'UTF-8' }).toString())
25+
packageJson.version = '1.99.0-SNAPSHOT'
26+
27+
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, undefined, ' '))
28+
29+
child_process.execSync(`vsce package`)
30+
31+
// Restore the original package.json.
32+
fs.copyFileSync(`${packageJsonFile}.bk`, packageJsonFile)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@
851851
"lint": "eslint -c .eslintrc.js --ext .ts .",
852852
"lintfix": "eslint -c .eslintrc.js --fix --ext .ts .",
853853
"package": "vsce package",
854-
"packageAlpha": "sed -i .bk 's/\\( \"version\":\\) .*/\\1 \"1.99.0-SNAPSHOT\",/' package.json && vsce package && mv package.json.bk package.json",
854+
"packageAlpha": "ts-node ./build-scripts/packageAlpha.ts",
855855
"install-plugin": "vsce package -o aws-toolkit-vscode-test.vsix && code --install-extension aws-toolkit-vscode-test.vsix",
856856
"generateTelemetry": "node node_modules/@aws-toolkits/telemetry/lib/generateTelemetry.js --extraInput=src/shared/telemetry/vscodeTelemetry.json --output=src/shared/telemetry/telemetry.gen.ts",
857857
"generateConfigurationAttributes": "ts-node ./build-scripts/generateConfigurationAttributes.ts",

0 commit comments

Comments
 (0)