Skip to content

Commit ad6325b

Browse files
committed
fix: move ng-package.schema.json to dist root directory
BREAKING CHANGES: the `ng-package.schema.json` was accidentally moved to `lib` folder in a previous release. Restore it in its original location!
1 parent b366a50 commit ad6325b

File tree

9 files changed

+31
-41
lines changed

9 files changed

+31
-41
lines changed

integration/samples.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require('ts-node').register({
1414
project: path.join(__dirname, '..', 'tsconfig.packagr.json')
1515
});
1616

17-
const ngPackagr = require('../lib/ng-packagr');
17+
const ngPackagr = require('../src/lib/ng-packagr');
1818

1919
let promise = Promise.resolve();
2020
while (SAMPLES.length > 0) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"prebuild": "rimraf dist && yarn schema",
7575
"build": "tsc -p tsconfig.packagr.json",
7676
"postbuild": "node scripts/postbuild.js",
77-
"schema": "json2ts --input src/lib/ng-package.schema.json --output src/lib/ng-package.schema.ts",
77+
"schema": "json2ts --input src/ng-package.schema.json --output src/ng-package.schema.ts",
7878
"prerelease": "yarn build",
7979
"release": "standard-version --message 'chore: cut release for v%s' --prerelease pre",
8080
"postrelease": "node scripts/prepublish.js",

scripts/postbuild.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const copy = (paths, opts) => {
1919
// copyfiles 'lib/conf/**/*.json' dist",
2020

2121
copy(['src/cli/*', 'dist'], {up: 1})
22-
.then(() => copy(['src/lib/ng-package.schema.json', 'dist'], {up: 1}))
22+
.then(() => copy(['src/ng-package.schema.json', 'dist'], {up: 1}))
2323
.then(() => copy(['src/lib/conf/**/*.json', 'dist'], {up: 1}))
2424
.catch((err) => {
2525
console.error("Cannot copy files", err);
File renamed without changes.

src/lib/model/ng-package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NgPackageConfig } from '../ng-package.schema';
1+
import { NgPackageConfig } from '../../ng-package.schema';
22
const path = require('path');
33

44
const SCOPE_PREFIX = '@';

src/lib/ng-packagr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { error, warn, info, success, debug } from './util/log';
1717

1818
// `ng-package.json` config
1919
import { NgPackage } from './model/ng-package';
20-
import { NgPackageConfig } from './ng-package.schema';
20+
import { NgPackageConfig } from '../ng-package.schema';
2121

2222

2323

src/lib/steps/package.ts

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,35 @@
11
import * as path from 'path';
22
import { SchemaClass, SchemaClassFactory } from '@ngtools/json-schema';
3-
import { NgPackageConfig } from '../ng-package.schema';
3+
import { NgPackageConfig } from '../../ng-package.schema';
44
import { NgPackage } from '../model/ng-package';
5-
import { findFromDirectory } from '../util/fs';
65
import { readJson, writeJson } from '../util/json';
76

7+
const schemaPromise = readJson(path.resolve(__dirname, '..', '..', 'ng-package.schema.json'))
8+
.then((jsonSchema: any) => SchemaClassFactory<NgPackageConfig>(jsonSchema));
89

910
/**
1011
* Reads an Angular package definition file from 'ng-package.json'
1112
*
12-
* @param file `ng-package.json` definition file
13+
* @param file path pointing to `ng-package.json` file
1314
*/
1415
export const readPackage = (file: string): Promise<NgPackage> => {
1516
const base = path.dirname(file);
1617

17-
return readJson(file)
18-
.then((ngPkg: NgPackageConfig) => {
19-
// resolve pathes relative to `ng-package.json` file
20-
const dir = path.resolve(base, ngPkg.src || '.');
18+
// read 'ng-package.json'
19+
return readJson(file).then((ngPkg: NgPackageConfig) => {
20+
// resolve pathes relative to `ng-package.json` file
21+
const dir = path.resolve(base, ngPkg.src || '.');
2122

22-
return readJson(`${dir}/package.json`)
23-
.then((pkg: any) => {
23+
// read 'package.json'
24+
return readJson(path.resolve(dir, 'package.json')).then((pkg: any) => {
25+
// read 'ng-package.schema.json'
26+
return schemaPromise.then((SchemaClass) => {
27+
const schema = new SchemaClass(ngPkg);
2428

25-
return new Promise((resolve, reject) => {
26-
27-
findFromDirectory(__dirname, 'ng-package.schema.json', (fileName: string) => {
28-
resolve(fileName);
29-
});
30-
})
31-
.then((schemaFileName: string) => readJson(schemaFileName))
32-
.then((schemaJson: any) => {
33-
const NgPackageSchema = SchemaClassFactory(schemaJson);
34-
const schema: SchemaClass<NgPackageConfig> = new NgPackageSchema(ngPkg);
35-
36-
return Promise.resolve(new NgPackage(base, schema.$$root(), pkg));
37-
});
38-
39-
});
29+
return Promise.resolve(new NgPackage(pkg, ngPkg, base, schema));
30+
});
4031
});
32+
});
4133
}
4234

4335

@@ -51,16 +43,14 @@ export const readPackage = (file: string): Promise<NgPackage> => {
5143
*/
5244
export const createPackage = (src: string, dest: string, additionalProperties?: {}): Promise<any> => {
5345

54-
return readJson(`${src}/package.json`)
55-
.then((packageJson) => {
46+
return readJson(path.resolve(src, 'package.json')).then((packageJson) => {
47+
// set additional properties
48+
if (additionalProperties) {
49+
Object.keys(additionalProperties).forEach((key) => {
50+
packageJson[key] = additionalProperties[key];
51+
});
52+
}
5653

57-
// set additional properties
58-
if (additionalProperties) {
59-
Object.keys(additionalProperties).forEach((key) => {
60-
packageJson[key] = additionalProperties[key];
61-
});
62-
}
63-
64-
return writeJson(packageJson, `${dest}/package.json`);
65-
});
54+
return writeJson(packageJson, `${dest}/package.json`);
55+
});
6656
}
File renamed without changes.

tsconfig.packagr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"inlineSources": true,
99
"declaration": true,
1010
"lib": ["es2015", "dom"],
11-
"outDir": "dist/lib",
11+
"outDir": "dist",
1212
"experimentalDecorators": true,
1313
"noEmitOnError": true,
1414
"noImplicitAny": false,

0 commit comments

Comments
 (0)