This repository has been archived by the owner on Jan 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove generator as dependency (#52)
* Install generator only if needed * Add E2E generator test * Install generator correctly if necessary * Fix test * Increase timeout * Add more output to clarify whats happening
- Loading branch information
Florian Richter
authored
Jan 17, 2020
1 parent
b8a8765
commit c2e7d7c
Showing
9 changed files
with
265 additions
and
652 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/*! | ||
* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. | ||
*/ | ||
|
||
import { PathLike } from 'fs'; | ||
import { resolve } from 'path'; | ||
import { Options } from 'yargs'; | ||
|
||
export interface GeneratorOptionsSDK { | ||
inputDir: PathLike; | ||
outputDir: PathLike; | ||
serviceMapping?: PathLike; | ||
useSwagger: boolean; | ||
writeReadme: boolean; | ||
changelogFile?: PathLike; | ||
forceOverwrite: boolean; | ||
clearOutputDir: boolean; | ||
aggregatorNpmPackageName?: string; | ||
aggregatorDirectoryName?: string; | ||
generateNpmrc: boolean; | ||
generateTypedocJson: boolean; | ||
generatePackageJson: boolean; | ||
generateJs: boolean; | ||
sdkAfterVersionScript: boolean; | ||
s4hanaCloud: boolean; | ||
generateCSN: boolean; | ||
} | ||
|
||
type KeysToOptions = { | ||
[optionName in keyof GeneratorOptionsSDK]: Options; | ||
}; | ||
|
||
export const generatorOptionsSDK: KeysToOptions = { | ||
inputDir: { | ||
alias: 'i', | ||
describe: 'This directory will be recursively searched for .edmx/.xml files.', | ||
normalize: true, | ||
coerce: resolve, | ||
type: 'string', | ||
demandOption: true, | ||
requiresArg: true | ||
}, | ||
outputDir: { | ||
alias: 'o', | ||
describe: 'Directory to save the generated code in.', | ||
normalize: true, | ||
coerce: resolve, | ||
type: 'string', | ||
demandOption: true, | ||
requiresArg: true | ||
}, | ||
serviceMapping: { | ||
alias: 's', | ||
describe: | ||
'Configuration file to ensure consistent names between multiple generation runs with updated / changed metadata files. Will be generated if not existent. By default it will be saved to/read from the input directory as "service-mapping.json".', | ||
type: 'string', | ||
coerce: resolve, | ||
normalize: true | ||
}, | ||
useSwagger: { | ||
describe: | ||
'Augment parsed information with information from swagger definition files. Files are expected to have the same name as the edmx file, but with .json as suffix.', | ||
type: 'boolean', | ||
default: false, | ||
hidden: true | ||
}, | ||
writeReadme: { | ||
describe: | ||
'When set to true, the generator will write a README.md file into the root folder of every package. This option does not make that much sense without also set useSwagger to "true".', | ||
type: 'boolean', | ||
default: false, | ||
hidden: true | ||
}, | ||
changelogFile: { | ||
describe: 'Path to file that will be copied into the generated packages under the filename CHANGELOG.md.', | ||
type: 'string', | ||
coerce: resolve, | ||
normalize: true, | ||
hidden: true | ||
}, | ||
forceOverwrite: { | ||
describe: | ||
'By default, the generator will exit when encountering a file that already exists. When set to true, it will be overwritten instead. Please note that compared to the --clearOutputDir option, this will not delete outdated files.', | ||
type: 'boolean', | ||
default: false | ||
}, | ||
clearOutputDir: { | ||
describe: 'When set to true, the generator will delete EVERYTHING in the specified output directory before generating code.', | ||
type: 'boolean', | ||
default: false | ||
}, | ||
aggregatorNpmPackageName: { | ||
describe: | ||
'When provided, the generator will generate an additional package with the provided name that has dependencies to all other generated packages.', | ||
type: 'string', | ||
hidden: true | ||
}, | ||
aggregatorDirectoryName: { | ||
describe: 'Hack for cloud-sdk-vdm package', | ||
type: 'string', | ||
hidden: true | ||
}, | ||
generateNpmrc: { | ||
describe: | ||
'By default, the generator will generate a .npmrc file specifying a registry for @sap scoped dependencies. When set to false, the generator will skip the generation of .npmrc.', | ||
type: 'boolean', | ||
default: true | ||
}, | ||
generateTypedocJson: { | ||
describe: | ||
'By default, the generator will generate a typedoc.json file for each package, used for the corresponding "doc" npm script. When set to false, the generator will skip the generation of the typedoc.json.', | ||
type: 'boolean', | ||
default: true | ||
}, | ||
generatePackageJson: { | ||
describe: | ||
'By default, the generator will generate a package.json file, specifying dependencies and scripts for compiling and generating documentation. When set to false, the generator will skip the generation of the package.json.', | ||
type: 'boolean', | ||
default: true | ||
}, | ||
generateJs: { | ||
describe: | ||
'By default, the generator will also generate transpiled .js, .js.map, .d.ts and .d.ts.map files. When set to false, the generator will only generate .ts files.', | ||
type: 'boolean', | ||
default: true | ||
}, | ||
sdkAfterVersionScript: { | ||
describe: 'When set to true, the package.json of generated services will have the after-version script to internally keep the versions in sync.', | ||
type: 'boolean', | ||
default: false, | ||
hidden: true | ||
}, | ||
s4hanaCloud: { | ||
describe: 'When set to true, the description of the generated packages will be specific to S/4HANA Cloud.', | ||
type: 'boolean', | ||
default: false, | ||
hidden: true | ||
}, | ||
generateCSN: { | ||
describe: 'When set to true a CSN file will be generated for each service definition in the output directory.', | ||
type: 'boolean', | ||
default: false | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*! | ||
* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. | ||
*/ | ||
jest.mock('cli-ux', () => ({ | ||
default: { | ||
confirm: jest.fn().mockResolvedValue(true) | ||
} | ||
})); | ||
|
||
import * as fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
import GenerateODataClient from '../src/commands/generate-odata-client'; | ||
|
||
describe('generate-odata-client', () => { | ||
const pathForTests = path.resolve(__dirname, __filename.replace(/\./g, '-')).replace('-ts', ''); | ||
|
||
beforeAll(() => { | ||
const pathForResources = path.resolve(__dirname, 'resources', 'template-generator-odata-client'); | ||
fs.copySync(pathForResources, pathForTests); | ||
}); | ||
|
||
afterAll(() => { | ||
fs.removeSync(pathForTests); | ||
}); | ||
|
||
it('[E2E] should generate a OData client', async () => { | ||
expect( | ||
await GenerateODataClient.run([ | ||
'-i', | ||
path.resolve(pathForTests, 'edmxSource'), | ||
'-o', | ||
path.resolve(pathForTests, 'output'), | ||
'--projectDir', | ||
pathForTests | ||
]) | ||
).toResolve(); | ||
|
||
expect(fs.readdirSync(path.resolve(pathForTests, 'output'))).toHaveLength(1); | ||
}, 120000); | ||
}); |
Oops, something went wrong.