Skip to content
This repository was archived by the owner on Jan 24, 2023. It is now read-only.

Commit 0df1f44

Browse files
jedsmith13mjaric
authored andcommitted
Made updates to implement Angular Starter Library. (#3)
There are some linting errors but it seems to build correctly.
1 parent 6592ec9 commit 0df1f44

21 files changed

+11948
-606
lines changed

.gitignore

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ npm-debug.log
55
# TypeScript
66
*.js
77
!rollup.config.js
8+
!build.js
9+
!rollup.es.config.js
10+
!spec.bundle.js
811
*.map
912
*.d.ts
1013
# JetBrains
@@ -23,4 +26,9 @@ Desktop.ini
2326
**/.DS_Store
2427
projectFilesBackup/
2528

26-
dist/
29+
/dist
30+
/documentation
31+
/coverage
32+
33+
*.log
34+
*.tgz

build.js

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
"use strict";
2+
3+
const shell = require('shelljs');
4+
const chalk = require('chalk');
5+
6+
const PACKAGE = `ng2-heremaps`;
7+
const NPM_DIR = `dist`;
8+
const ESM2015_DIR = `${NPM_DIR}/esm2015`;
9+
const ESM5_DIR = `${NPM_DIR}/esm5`;
10+
const FESM2015_DIR = `${NPM_DIR}/fesm2015`;
11+
const FESM5_DIR = `${NPM_DIR}/fesm5`;
12+
const BUNDLES_DIR = `${NPM_DIR}/bundles`;
13+
const OUT_DIR = `${NPM_DIR}/package`;
14+
const OUT_DIR_ESM5 = `${NPM_DIR}/package/esm5`;
15+
16+
shell.echo(`Start building...`);
17+
18+
shell.rm(`-Rf`, `${NPM_DIR}/*`);
19+
shell.mkdir(`-p`, `./${ESM2015_DIR}`);
20+
shell.mkdir(`-p`, `./${ESM5_DIR}`);
21+
shell.mkdir(`-p`, `./${FESM2015_DIR}`);
22+
shell.mkdir(`-p`, `./${FESM5_DIR}`);
23+
shell.mkdir(`-p`, `./${BUNDLES_DIR}`);
24+
shell.mkdir(`-p`, `./${OUT_DIR}`);
25+
26+
/* TSLint with Codelyzer */
27+
// https://github.com/palantir/tslint/blob/master/src/configs/recommended.ts
28+
// https://github.com/mgechev/codelyzer
29+
shell.echo(`Start TSLint`);
30+
shell.exec(`tslint -p tsconfig.json -t stylish src/**/*.ts`);
31+
shell.echo(chalk.green(`TSLint completed`));
32+
33+
shell.cp(`-Rf`, [`src`, `*.ts`, `*.json`], `${OUT_DIR}`);
34+
35+
/* Try to process scss files */
36+
shell.echo(`Try to process scss files`);
37+
if (shell.exec(`node-sass -r ${OUT_DIR} -o ${OUT_DIR}`).code === 0) {
38+
shell.rm(`-Rf`, `${OUT_DIR}/**/*.scss`);
39+
shell.ls(`${OUT_DIR}/**/*.css`).forEach(function (file) {
40+
shell.mv(file, file.replace('.css', '.scss'));
41+
});
42+
}
43+
44+
/* AoT compilation */
45+
shell.echo(`Start AoT compilation`);
46+
if (shell.exec(`ngc -p ${OUT_DIR}/tsconfig-build.json`).code !== 0) {
47+
shell.echo(chalk.red(`Error: AoT compilation failed`));
48+
shell.exit(1);
49+
}
50+
shell.echo(chalk.green(`AoT compilation completed`));
51+
52+
shell.echo(`Copy ES2015 for package`);
53+
shell.cp(`-Rf`, [`${NPM_DIR}/src/`, `${NPM_DIR}/*.js`, `${NPM_DIR}/*.js.map`], `${ESM2015_DIR}`);
54+
55+
/* BUNDLING PACKAGE */
56+
shell.echo(`Start bundling`);
57+
shell.echo(`Rollup package`);
58+
if (shell.exec(`rollup -c rollup.es.config.js -i ${NPM_DIR}/${PACKAGE}.js -o ${FESM2015_DIR}/${PACKAGE}.js`).code !== 0) {
59+
shell.echo(chalk.red(`Error: Rollup package failed`));
60+
shell.exit(1);
61+
}
62+
63+
shell.echo(`Produce ESM5/FESM5 versions`);
64+
shell.exec(`ngc -p ${OUT_DIR}/tsconfig-build.json --target es5 -d false --outDir ${OUT_DIR_ESM5} --sourceMap`);
65+
shell.cp(`-Rf`, [`${OUT_DIR_ESM5}/src/`, `${OUT_DIR_ESM5}/*.js`, `${OUT_DIR_ESM5}/*.js.map`], `${ESM5_DIR}`);
66+
if (shell.exec(`rollup -c rollup.es.config.js -i ${OUT_DIR_ESM5}/${PACKAGE}.js -o ${FESM5_DIR}/${PACKAGE}.js`).code !== 0) {
67+
shell.echo(chalk.red(`Error: FESM5 version failed`));
68+
shell.exit(1);
69+
}
70+
71+
shell.echo(`Run Rollup conversion on package`);
72+
if (shell.exec(`rollup -c rollup.config.js -i ${FESM5_DIR}/${PACKAGE}.js -o ${BUNDLES_DIR}/${PACKAGE}.umd.js`).code !== 0) {
73+
shell.echo(chalk.red(`Error: Rollup conversion failed`));
74+
shell.exit(1);
75+
}
76+
77+
shell.echo(`Minifying`);
78+
shell.cd(`${BUNDLES_DIR}`);
79+
if (shell.exec(`uglifyjs ${PACKAGE}.umd.js -c --comments -o ${PACKAGE}.umd.min.js --source-map "includeSources=true,filename='${PACKAGE}.umd.min.js.map'"`).code !== 0) {
80+
shell.echo(chalk.red(`Error: Minifying failed`));
81+
shell.exit(1);
82+
}
83+
shell.cd(`..`);
84+
shell.cd(`..`);
85+
86+
shell.echo(chalk.green(`Bundling completed`));
87+
88+
shell.rm(`-Rf`, `${NPM_DIR}/package`);
89+
shell.rm(`-Rf`, `${NPM_DIR}/*.js`);
90+
shell.rm(`-Rf`, `${NPM_DIR}/*.js.map`);
91+
shell.rm(`-Rf`, `${NPM_DIR}/src/**/*.js`);
92+
shell.rm(`-Rf`, `${NPM_DIR}/src/**/*.js.map`);
93+
shell.rm(`-Rf`, `${ESM2015_DIR}/src/**/*.d.ts`);
94+
95+
shell.cp(`-Rf`, [`package.json`, `LICENSE`, `README.md`], `${NPM_DIR}`);
96+
97+
shell.sed('-i', `"private": true,`, `"private": false,`, `./${NPM_DIR}/package.json`);
98+
99+
shell.echo(chalk.green(`End building`));

license-banner.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* @license ng2-heremaps
3+
* MIT license
4+
*/

ng2-heremaps.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// This file is not used to build the module. It is only used during editing
2+
// by the TypeScript language service and during build for verification. `ngc`
3+
// replaces this file with production ng2-heremaps.ts when it rewrites
4+
// private symbol names.
5+
6+
export * from './public_api';

0 commit comments

Comments
 (0)