Skip to content
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

Fix some templates permissions and convert blueprint cli to cjs #23442

Merged
merged 3 commits into from
Sep 8, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports[`generator - generate-blueprint with all option should match snapshot 1`
"README.md": {
"stateCleared": "modified",
},
"cli/cli.mjs": {
"cli/cli.cjs": {
"stateCleared": "modified",
},
"generators/angular/command.mjs": {
Expand Down Expand Up @@ -898,7 +898,7 @@ exports[`generator - generate-blueprint with default config should write files a
"README.md": {
"stateCleared": "modified",
},
"cli/cli.mjs": {
"cli/cli.cjs": {
"stateCleared": "modified",
},
"package.json": {
Expand Down
2 changes: 1 addition & 1 deletion generators/generate-blueprint/files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const files = {
},
{
condition: ctx => ctx.cli,
templates: [{ file: 'cli/cli.mjs', renameTo: ctx => (ctx.js ? 'cli/cli.cjs' : 'cli/cli.mjs') }],
templates: ['cli/cli.cjs'],
},
{
condition: ctx => ctx.commands.length > 0,
Expand Down
2 changes: 1 addition & 1 deletion generators/generate-blueprint/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export default class extends BaseGenerator {
const { baseName, cliName = `jhipster-${baseName}` } = this.application;
this.packageJson.merge({
bin: {
[cliName]: `cli/cli.${this.jhipsterConfig.js ? '' : 'm'}js`,
[cliName]: 'cli/cli.cjs',
},
files: ['cli', 'generators'],
});
Expand Down
Empty file modified generators/generate-blueprint/generator.spec.mjs
100755 → 100644
Empty file.
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#!/usr/bin/env node

import { runJHipster, done, logger } from 'generator-jhipster/cli';
import { readFile } from 'fs/promises';
import { fileURLToPath } from 'url';
import { dirname, basename } from 'path';
const { dirname, basename, join } = require('path');
const { version, bin } = require('../package.json');

// Get package name to use as namespace.
// Allows blueprints to be aliased.
const packagePath = dirname(dirname(fileURLToPath(import.meta.url)));
const packagePath = dirname(__dirname);
const packageFolderName = basename(packagePath);

(async () => {
const { version, bin } = JSON.parse(await readFile(new URL('../package.json', import.meta.url)));
const { runJHipster, done, logger } = await import('generator-jhipster/cli');
const executableName = Object.keys(bin)[0];

runJHipster({
Expand All @@ -27,9 +25,9 @@ const packageFolderName = basename(packagePath);
},
lookups: [{ packagePaths: [packagePath], lookups: ['generators'] }],
}).catch(done);
})();

process.on('unhandledRejection', up => {
logger.error('Unhandled promise rejection at:');
logger.fatal(up);
});
process.on('unhandledRejection', up => {
logger.error('Unhandled promise rejection at:');
logger.fatal(up);
});
})();
Empty file.
Loading