Skip to content

Commit eb35550

Browse files
authored
chore: rename npm script and update package generation command (#212)
1 parent 4053dd9 commit eb35550

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ Please be aware of the following notes prior to opening a pull request:
7070
a breaking change, the commit message must end with a single paragraph: `BREAKING
7171
CHANGE: a description of what broke`
7272

73-
5. After getting ready to open a pull request, make sure to run the `scripts/
74-
rebuildClients.js` to re-generate all the service clients, and commit the
75-
change(if any) to a standalone commit following the guide above.
73+
5. After getting ready to open a pull request, make sure to run the `npm run update-clients`
74+
to re-generate all the service clients, and commit the change(if any) to a
75+
standalone commit following the guide above.
7676

7777
### Setup and Testing
7878

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"clean": "npm run clear-build-cache && lerna clean",
1010
"clear-build-cache": "rimraf ./packages/*/build/*",
1111
"copy-models": "node ./scripts/copyModels.js",
12+
"update-clients": "node ./scripts/rebuildClients.js",
1213
"pretest": "lerna run pretest",
1314
"test": "jest --coverage"
1415
},

packages/package-generator/src/commands/ImportClientPackageCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const ImportClientPackageCommand: yargs.CommandModule = {
2323
runtime: {
2424
alias: ['r'],
2525
type: 'string',
26-
choices: ['node', 'browser', 'universal'],
26+
choices: ['node', 'browser'],
2727
demandOption: true,
2828
},
2929
smoke: {

packages/package-generator/src/commands/ImportModelsCommand.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { clientModuleIdentifier } from '../clientModuleIdentifier';
2-
import { fromModelJson, fromSmokeTestModelJson } from '@aws-sdk/service-model';
2+
import { fromModelJson } from '@aws-sdk/service-model';
33
import { TreeModel, SmokeTestModel } from '@aws-sdk/build-types';
4-
import { existsSync, readFileSync } from 'fs';
5-
import { dirname, join } from 'path';
4+
import { readFileSync } from 'fs';
5+
import { dirname } from 'path';
66
import * as yargs from 'yargs';
77
import { sync as globSync } from 'glob';
88
import { ImportClientPackageCommand } from './ImportClientPackageCommand';
@@ -11,6 +11,8 @@ import {loadSmokeTestModel} from '../loadSmokeTestModel';
1111
interface ImportModelsCommandArgs {
1212
matching: string;
1313
ignore?: string|Array<string>;
14+
runtime?: string,
15+
version?: string
1416
}
1517

1618
interface ServicesMapValue {
@@ -23,18 +25,28 @@ export const ImportModelsCommand: yargs.CommandModule = {
2325

2426
aliases: ['import-models'],
2527

26-
describe: 'Create a client for all runtimes for all service models under the provided directory. The generated packages will be added to the AWS SDK for JavaScript repository if they are not already present.',
28+
describe: 'Create a client for all runtimes for all service models under the provided directory. The generated packages will be added to the AWS SDK for JavaScript repository if they are not already present. ' +
29+
'Specified runtime or version is also supported',
2730

2831
builder: {
2932
matching: {
3033
alias: ['m'],
3134
type: 'string',
3235
demandOption: true,
3336
},
34-
ignore: { type: 'string' }
37+
ignore: { type: 'string' },
38+
runtime: {
39+
alias: ['r'],
40+
type: 'string',
41+
choices: ['node', 'browser'],
42+
},
43+
version: {
44+
alias: ['v'],
45+
type: 'string',
46+
}
3547
} as yargs.CommandBuilder,
3648

37-
handler({ignore, matching}: ImportModelsCommandArgs): void {
49+
handler({ignore, matching, runtime, version}: ImportModelsCommandArgs): void {
3850
const services = new Map<string, ServicesMapValue>();
3951
for (const match of globSync(matching, {ignore})) {
4052
const model = fromModelJson(readFileSync(match, 'utf8'));
@@ -51,11 +63,14 @@ export const ImportModelsCommand: yargs.CommandModule = {
5163
}
5264

5365
console.log(`Generating ${services.size} SDK packages...`);
54-
5566
for (const [identifier, {model, smoke}] of services) {
56-
for (const runtime of ['node', 'browser']) {
57-
console.log(`Generating ${runtime} ${clientModuleIdentifier(model.metadata)} SDK`);
58-
ImportClientPackageCommand.handler({ model, runtime, smoke });
67+
console.log(`Generating ${runtime} ${clientModuleIdentifier(model.metadata)} SDK`);
68+
if (runtime) {
69+
ImportClientPackageCommand.handler({ model, runtime, smoke, version });
70+
} else {
71+
for (const runtime of ['node', 'browser']) {
72+
ImportClientPackageCommand.handler({ model, runtime, smoke, version });
73+
}
5974
}
6075
}
6176
}

scripts/rebuildClients.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ for (const serviceClient of existingServiceClients) {
3434
console.info(`generating ${runtime} client from model at ${models.service}`)
3535
generateClient(models, runtime);
3636
}
37-
3837
console.log('done!');
3938

40-
4139
function grabExistingClients() {
4240
const packagesDir = path.join(path.dirname(__dirname), 'packages');
4341
const clientPackagesPaths = [];

0 commit comments

Comments
 (0)