Skip to content

Commit 09b011f

Browse files
committed
feat(cli): add --compile flag to generate fromTemplate command
1 parent 92767d9 commit 09b011f

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"devDependencies": {
5959
"@asyncapi/minimaltemplate": "./test/fixtures/minimaltemplate",
6060
"@asyncapi/newtemplate": "./test/fixtures/newtemplate",
61+
"@eslint/js": "^9.39.2",
6162
"@oclif/test": "^3.2.15",
6263
"@types/archiver": "^7.0.0",
6364
"@types/body-parser": "^1.19.6",
@@ -76,18 +77,17 @@
7677
"@types/ws": "^8.18.1",
7778
"@typescript-eslint/eslint-plugin": "^8.50.0",
7879
"@typescript-eslint/parser": "^8.50.0",
80+
"c8": "^10.1.3",
7981
"chai": "^6.2.1",
8082
"cross-env": "^10.1.0",
8183
"eslint": "^9.39.2",
82-
"@eslint/js": "^9.39.2",
8384
"eslint-config-oclif": "^6",
8485
"eslint-plugin-github": "^6.0.0",
8586
"eslint-plugin-security": "^3.0.1",
8687
"eslint-plugin-sonarjs": "^3.0.5",
8788
"markdown-toc": "^1.2.0",
8889
"mocha": "^11.7.5",
8990
"nodemon": "^3.1.11",
90-
"c8": "^10.1.3",
9191
"puppeteer": "^24.33.0",
9292
"rimraf": "^6.1.2",
9393
"simple-git": "^3.30.0",

src/apps/cli/internal/base/BaseGeneratorCommand.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface GeneratorOptions {
2121
forceWrite: boolean;
2222
install: boolean;
2323
debug: boolean;
24+
compile: boolean;
2425
templateParams: any;
2526
noOverwriteGlobs: string[];
2627
mapBaseUrlToFolder: any;
@@ -49,6 +50,7 @@ export abstract class BaseGeneratorCommand extends Command {
4950
forceWrite: flags['force-write'],
5051
install: flags.install,
5152
debug: flags.debug,
53+
compile: flags.compile,
5254
templateParams: parsedFlags.params,
5355
noOverwriteGlobs: flags['no-overwrite'],
5456
mapBaseUrlToFolder: parsedFlags.mapBaseUrlToFolder,

src/apps/cli/internal/flags/generate/sharedFlags.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,9 @@ export const sharedFlags = {
5454
'registry-token': Flags.string({
5555
description: 'The npm registry authentication token, that can be passed instead of base64 encoded username and password'
5656
}),
57+
compile: Flags.boolean({
58+
default: true,
59+
allowNo: true,
60+
description: 'Compile the template (set to false to use cached transpiled version, defaults to true)'
61+
}),
5762
};

test/integration/generate/fromTemplate.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,23 @@ describe('template', () => {
228228
}
229229
);
230230
});
231+
232+
describe('compile flag', () => {
233+
test
234+
.stdout()
235+
.command([
236+
...generalOptions,
237+
'--output=./test/docs/9',
238+
'--force-write',
239+
'--no-compile',
240+
nonInteractive
241+
])
242+
.it('should generate template with compile flag disabled', (ctx, done) => {
243+
expect(ctx.stdout).to.contain(
244+
'Check out your shiny new generated files at ./test/docs/9.\n\n'
245+
);
246+
cleanup('./test/docs/9');
247+
done();
248+
});
249+
});
231250
});

0 commit comments

Comments
 (0)