Skip to content

Commit a517160

Browse files
committed
build: fix order of JSON help generation
Previoiusly we generated the JSON help files prior to building which caused the `help` directory in the `dist` to be deleted.
1 parent 8673e3d commit a517160

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

scripts/json-help.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,27 @@ import * as path from 'path';
1515
import { packages } from '../lib/packages';
1616
import create from './create';
1717

18-
export default async function (opts = {}, logger: logging.Logger) {
18+
export async function createTemporaryProject(logger: logging.Logger): Promise<string> {
1919
logger.info('Creating temporary project...');
2020
const newProjectTempRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'angular-cli-create-'));
2121
const newProjectName = 'help-project';
2222
const newProjectRoot = path.join(newProjectTempRoot, newProjectName);
2323
await create({ _: [newProjectName] }, logger.createChild('create'), newProjectTempRoot);
2424

25+
return newProjectRoot;
26+
}
27+
28+
export interface JsonHelpOptions {
29+
temporaryProjectRoot?: string;
30+
}
31+
32+
export default async function ({ temporaryProjectRoot }: JsonHelpOptions, logger: logging.Logger) {
2533
logger.info('Gathering JSON Help...');
34+
35+
const newProjectRoot = temporaryProjectRoot ?? (await createTemporaryProject(logger));
2636
const ngPath = path.join(newProjectRoot, 'node_modules/.bin/ng');
2737
const helpOutputRoot = path.join(packages['@angular/cli'].dist, 'help');
38+
2839
await fs.mkdir(helpOutputRoot);
2940

3041
const runNgCommandJsonHelp = async (args: string[]) => {

scripts/snapshots.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import * as os from 'os';
1313
import * as path from 'path';
1414
import { PackageInfo, packages } from '../lib/packages';
1515
import build from './build-bazel';
16-
import jsonHelp from './json-help';
16+
import jsonHelp, { createTemporaryProject } from './json-help';
1717

1818
// Added to the README.md of the snapshot. This is markdown.
1919
const readmeHeaderFn = (pkg: PackageInfo) => `
@@ -164,12 +164,16 @@ export default async function (opts: SnapshotsOptions, logger: logging.Logger) {
164164
_exec('git', ['config', '--global', 'push.default', 'simple'], {}, logger);
165165
}
166166

167-
await jsonHelp(undefined, logger);
167+
// This is needed as otherwise when we run `devkit admin create` after `bazel build` the `dist`
168+
// will be overridden with the output of the legacy build.
169+
const temporaryProjectRoot = await createTemporaryProject(logger);
168170

169171
// Run build.
170172
logger.info('Building...');
171173
await build({ snapshot: true }, logger.createChild('build'));
172174

175+
await jsonHelp({ temporaryProjectRoot }, logger);
176+
173177
if (!githubToken) {
174178
logger.info('No token given, skipping actual publishing...');
175179

0 commit comments

Comments
 (0)