Skip to content
This repository has been archived by the owner on Apr 23, 2022. It is now read-only.

Commit

Permalink
bug fix: update extension id in template files in nightly build
Browse files Browse the repository at this point in the history
  • Loading branch information
dilin-MS2 committed Jan 8, 2020
1 parent 053089b commit f5d56a8
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions scripts/updateConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (process.env.DEPLOY_TO_MARKETPLACE === "true") {
const nightlyBuildName = "test-owl-project-nightly";
const nightlyBuildDisplayName = "Test OWL Project (Nightly)";
const nightlyBuildPublisher = "IoTDevExBuild";
modifyPackageJsonForNonProduction(packageJson, nightlyBuildName, nightlyBuildDisplayName, nightlyBuildPublisher);
updateConfigForNonProduction(packageJson, nightlyBuildName, nightlyBuildDisplayName, nightlyBuildPublisher);
} else if (process.env.IS_PROD) {
// Update resource link
const codeGenUrl = "https://aka.ms/iot-codegen-cli-for-workbench";
Expand All @@ -27,21 +27,7 @@ if (process.env.DEPLOY_TO_MARKETPLACE === "true") {
const testName = "test-owl-project";
const testDisplayName = "Test OWL Project RC";
const testPublisher = "IoTDevExBuild";
modifyPackageJsonForNonProduction(packageJson, testName, testDisplayName, testPublisher);

// Modify extensionId in template files
const extensionIdPattern = /vsciot-vscode.vscode-iot-workbench/g;
const rcExtensionId = 'iotdevexbuild.test-owl-project';

const arm7DevcontainerJsonFile = "resources/templates/arm7/devcontainer.json";
const arm8DevcontainerJsonFile = "resources/templates/arm8/devcontainer.json";
const x86DevcontainerJsonFile = "resources/templates/x86/devcontainer.json";
const files = [arm7DevcontainerJsonFile, arm8DevcontainerJsonFile, x86DevcontainerJsonFile];
files.forEach(filePath => {
const originalJsonFile = fs.readFileSync(filePath).toString();
const replaceJson = originalJsonFile.replace(extensionIdPattern, rcExtensionId);
fs.writeFileSync(filePath, replaceJson);
});
updateConfigForNonProduction(packageJson, testName, testDisplayName, testPublisher);
}

fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2) + '\n');
Expand All @@ -50,12 +36,14 @@ if (process.env.DEPLOY_TO_MARKETPLACE === "true") {
/**
* Update package.json with test name, displayName, publisher, ai aky.
* Trim version number. Delete extension icon.
* Update extension id in template files.
* @param {*} packageJson package json oject
* @param {*} testName test extension name
* @param {*} testDisplayName test extension displate name
* @param {*} testPublisher test publisher
*/
function modifyPackageJsonForNonProduction(packageJson, testName, testDisplayName, testPublisher) {
function updateConfigForNonProduction(packageJson, testName, testDisplayName, testPublisher) {
// Update package.json
packageJson.name = testName;
packageJson.displayName = testDisplayName;
packageJson.publisher = testPublisher;
Expand All @@ -68,4 +56,18 @@ function modifyPackageJsonForNonProduction(packageJson, testName, testDisplayNam
}

delete packageJson.icon;

// Modify extensionId in template files
const extensionIdPattern = /vsciot-vscode.vscode-iot-workbench/g;
const testExtensionId = testPublisher + '.' + testName;

const arm7DevcontainerJsonFile = "resources/templates/arm7/devcontainer.json";
const arm8DevcontainerJsonFile = "resources/templates/arm8/devcontainer.json";
const x86DevcontainerJsonFile = "resources/templates/x86/devcontainer.json";
const files = [arm7DevcontainerJsonFile, arm8DevcontainerJsonFile, x86DevcontainerJsonFile];
files.forEach(filePath => {
const originalJsonFile = fs.readFileSync(filePath).toString();
const replaceJson = originalJsonFile.replace(extensionIdPattern, testExtensionId.toLowerCase());
fs.writeFileSync(filePath, replaceJson);
});
}

0 comments on commit f5d56a8

Please sign in to comment.