Skip to content

chore: rename npm script and update package generation command #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ Please be aware of the following notes prior to opening a pull request:
a breaking change, the commit message must end with a single paragraph: `BREAKING
CHANGE: a description of what broke`

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

### Setup and Testing

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"clean": "npm run clear-build-cache && lerna clean",
"clear-build-cache": "rimraf ./packages/*/build/*",
"copy-models": "node ./scripts/copyModels.js",
"update-clients": "node ./scripts/rebuildClients.js",
"pretest": "lerna run pretest",
"test": "jest --coverage"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ImportClientPackageCommand: yargs.CommandModule = {
runtime: {
alias: ['r'],
type: 'string',
choices: ['node', 'browser', 'universal'],
choices: ['node', 'browser'],
demandOption: true,
},
smoke: {
Expand Down
35 changes: 25 additions & 10 deletions packages/package-generator/src/commands/ImportModelsCommand.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { clientModuleIdentifier } from '../clientModuleIdentifier';
import { fromModelJson, fromSmokeTestModelJson } from '@aws-sdk/service-model';
import { fromModelJson } from '@aws-sdk/service-model';
import { TreeModel, SmokeTestModel } from '@aws-sdk/build-types';
import { existsSync, readFileSync } from 'fs';
import { dirname, join } from 'path';
import { readFileSync } from 'fs';
import { dirname } from 'path';
import * as yargs from 'yargs';
import { sync as globSync } from 'glob';
import { ImportClientPackageCommand } from './ImportClientPackageCommand';
Expand All @@ -11,6 +11,8 @@ import {loadSmokeTestModel} from '../loadSmokeTestModel';
interface ImportModelsCommandArgs {
matching: string;
ignore?: string|Array<string>;
runtime?: string,
version?: string
}

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

aliases: ['import-models'],

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.',
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. ' +
'Specified runtime or version is also supported',

builder: {
matching: {
alias: ['m'],
type: 'string',
demandOption: true,
},
ignore: { type: 'string' }
ignore: { type: 'string' },
runtime: {
alias: ['r'],
type: 'string',
choices: ['node', 'browser'],
},
version: {
alias: ['v'],
type: 'string',
}
} as yargs.CommandBuilder,

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

console.log(`Generating ${services.size} SDK packages...`);

for (const [identifier, {model, smoke}] of services) {
for (const runtime of ['node', 'browser']) {
console.log(`Generating ${runtime} ${clientModuleIdentifier(model.metadata)} SDK`);
ImportClientPackageCommand.handler({ model, runtime, smoke });
console.log(`Generating ${runtime} ${clientModuleIdentifier(model.metadata)} SDK`);
if (runtime) {
ImportClientPackageCommand.handler({ model, runtime, smoke, version });
} else {
for (const runtime of ['node', 'browser']) {
ImportClientPackageCommand.handler({ model, runtime, smoke, version });
}
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions scripts/rebuildClients.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ for (const serviceClient of existingServiceClients) {
console.info(`generating ${runtime} client from model at ${models.service}`)
generateClient(models, runtime);
}

console.log('done!');


function grabExistingClients() {
const packagesDir = path.join(path.dirname(__dirname), 'packages');
const clientPackagesPaths = [];
Expand Down