Skip to content

Commit 1f23ac0

Browse files
committed
add --set-dependencies flag
1 parent d3518eb commit 1f23ac0

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

libraries/botbuilder-vendors/src/actions/install.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { logger } from '../utils';
1616
* @param param0.pkgDir Directory of the package.
1717
* @param param0.directory Directory to install vendor packages.
1818
*/
19-
export async function install({ vendors, dependencies, pkgDir, directory }: any) {
19+
export async function install({ vendors, dependencies, pkgDir, directory, shouldSetDependencies }: any) {
2020
for (let i = 0; i < vendors.length; i++) {
2121
const vendor = vendors[i];
2222

@@ -42,12 +42,12 @@ export async function install({ vendors, dependencies, pkgDir, directory }: any)
4242
await copyFile(source, destination);
4343
}
4444

45-
logger.package.dependencies.header({ dependencies: dependencies.length });
45+
logger.package.dependencies.header({ dependencies: dependencies.length, shouldSetDependencies });
4646
for (let i = 0; i < dependencies.length; i++) {
4747
const { name, version } = dependencies[i];
4848
logger.package.dependencies.dependency({ isLast: i === dependencies.length - 1, name, version });
49-
if (process.env.GITHUB_ACTIONS === 'true') {
50-
// Only modify package.json if running in GitHub Actions, preventing changes to local files and pushing them back to the repository.
49+
if (shouldSetDependencies) {
50+
// Only modify package.json if the flag is set, preventing changes to local files and pushing them back to the repository.
5151
execSync(`npm pkg set dependencies["${name}"]="${version}"`, { cwd: pkgDir });
5252
}
5353
}

libraries/botbuilder-vendors/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ const VENDORS_DIR = 'libraries/botbuilder-vendors/vendors';
1717

1818
export const command = (argv: string[]) => async () => {
1919
try {
20-
const flags = minimist(argv);
20+
const flags = minimist(argv, {
21+
alias: { setDependencies: 'set-dependencies' },
22+
default: { setDependencies: false },
23+
});
2124
const action = flags._[0];
2225
if (!actions.valid(action)) {
2326
throw failures.actionNotFound(action);
@@ -55,7 +58,7 @@ export const command = (argv: string[]) => async () => {
5558

5659
logger.package.vendors.header({ vendors: newVendors.length });
5760

58-
await install({ vendors: newVendors, dependencies, pkgDir, directory });
61+
await install({ vendors: newVendors, dependencies, pkgDir, directory, shouldSetDependencies: flags.setDependencies });
5962
await build({ pkgDir, vendors, directory });
6063

6164
logger.package.footer();

libraries/botbuilder-vendors/src/utils/logger.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ export const logger = {
6161
},
6262
},
6363
dependencies: {
64-
header({ dependencies }: any) {
65-
const tags = dependencies > 0 ? [`${colors.green}[added]`] : [`${colors.red}[not found]`];
64+
header({ dependencies, shouldSetDependencies }: any) {
65+
const tags = shouldSetDependencies ? dependencies > 0 ? [`${colors.green}[added]`] : [`${colors.red}[not found]`] : [`${colors.blue}[skipped]`];
66+
tags.push(`${colors.yellow}[--set-dependencies=${shouldSetDependencies}]`)
6667
console.log(
6768
`├─ dependencies: ${colors.magenta}${dependencies} ${plural(dependencies, 'package')} ${tags.join('')}${colors.reset}`,
6869
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"test:runtime:min": "wsrun -m -p \"botbuilder-dialogs-adaptive-runtime*\" -t test:min",
6666
"test:schemas": "mocha libraries/botbuilder-dialogs-declarative/tests/schemaMergeTest.js --exit --bail",
6767
"update-versions": "yarn workspace botbuilder-repo-utils update-versions",
68-
"postupdate-versions": "yarn workspace botbuilder-vendors connect"
68+
"postupdate-versions": "yarn workspace botbuilder-vendors connect --set-dependencies"
6969
},
7070
"resolutions": {
7171
"**/botbuilder-dialogs-adaptive-runtime-integration-restify/restify/send": "^0.19.0",

0 commit comments

Comments
 (0)