Skip to content

Commit

Permalink
build: add preview package support (#1490)
Browse files Browse the repository at this point in the history
* build: add preview package support

* build: tweak logging

* build: get preview version from argv

* build: handle previewVersion not being set

* build: streaming is GA now
  • Loading branch information
Christopher Anderson authored Dec 10, 2019
1 parent 324a116 commit ac06ba2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build-docs": "lerna run build-docs",
"eslint": "eslint ./libraries/*/src/*.ts ./libraries/*/src/**/*.ts",
"eslint-fix": "eslint ./libraries/*/src/*.ts ./libraries/*/src/**/*.ts --fix",
"set-dependency-versions": "node tools/util/updateDependenciesInPackageJsons.js ./libraries ${Version} botframework-expressions botbuilder-lg botframework-streaming botbuilder botbuilder-ai botbuilder-dialogs botbuilder-core botbuilder-applicationinsights botbuilder-testing botframework-connector botframework-config botframework-schema testbot && node tools/util/updateDependenciesInPackageJsons.js ./transcripts ${Version} botbuilder botbuilder-ai botbuilder-dialogs",
"set-dependency-versions": "node tools/util/updateDependenciesInPackageJsons.js ./libraries ${Version} ${PreviewPackageVersion} botframework-expressions botbuilder-lg botframework-streaming botbuilder botbuilder-ai botbuilder-dialogs botbuilder-core botbuilder-applicationinsights botbuilder-testing botframework-connector botframework-config botframework-schema testbot && node tools/util/updateDependenciesInPackageJsons.js ./transcripts ${Version} botbuilder botbuilder-ai botbuilder-dialogs",
"update-versions": "lerna run set-version && npm run set-dependency-versions"
},
"dependencies": {
Expand Down
21 changes: 18 additions & 3 deletions tools/util/updateDependenciesInPackageJsons.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ console.log('Started ' + (new Date()));
var myArgs = process.argv.slice(2);
var rootPath = myArgs[0];
var newVersion = myArgs[1];
var dependencies = myArgs.slice(2);
var previewVersion = myArgs[2] || process.env.PreviewPackageVersion;
// This is a hack to deal with the inconsistencies between CI and daily builds right now
if(previewVersion === 'botframework-expressions') {
previewVersion = undefined;
}
var previewPackages = {
'botbuilder-lg': true,
'botframework-expressions': true
}
var dependencies = myArgs.slice(previewVersion ? 3 : 2);
console.log('newVersion =', newVersion);
console.log('previewVersion = ' + previewVersion);
console.log('dependencies =');
console.log(dependencies);
console.log('Preview packages: ');
console.log(JSON.stringify(previewPackages, null, ' '));

// Update versions for specified dependencies in package.json file
function updateDependencies(filePath) {
Expand All @@ -20,10 +32,13 @@ function updateDependencies(filePath) {
return console.log(err);
}

console.log('Updating file: ' + filePath);

var result = '';
dependencies.forEach(function (dependency) {
var findString = new RegExp('("dependencies":)(.+?)("' + dependency + '":\\s*")([^\/"]+)', "gms")
var replaceString = '$1$2$3' + newVersion;
var findString = new RegExp('("dependencies":)(.+?)("' + dependency + '":\\s*")([^\/"]+)', 'gms')
var replaceString = '$1$2$3' + ((previewVersion && previewPackages[dependency]) ? previewVersion : newVersion);
console.log('Replace string: ' + replaceString);
result = data.replace(findString, replaceString);
data = result;
});
Expand Down

0 comments on commit ac06ba2

Please sign in to comment.