├── test
└── fixtures
│ ├── allow-empty-scss-files
│ ├── input
│ │ ├── basic.component.scss
│ │ ├── basic.component.html
│ │ ├── module.ts
│ │ └── basic.component.ts
│ └── output-expected
│ │ ├── module.d.ts
│ │ ├── basic.component.d.ts
│ │ ├── .npmignore
│ │ ├── module.ts
│ │ ├── basic.component.ts
│ │ ├── module.js.map
│ │ ├── basic.component.js.map
│ │ ├── tsconfig-ngc.json
│ │ ├── .gitignore
│ │ ├── module.metadata.json
│ │ ├── basic.component.metadata.json
│ │ ├── module.js
│ │ ├── LICENSE
│ │ ├── basic.component.js
│ │ ├── package.json
│ │ └── README.md
│ ├── basic-html-no-css-with-spec-files
│ ├── input
│ │ ├── basic.component.spec.ts
│ │ ├── basic.component.html
│ │ ├── module.ts
│ │ └── basic.component.ts
│ └── output-expected
│ │ ├── module.d.ts
│ │ ├── basic.component.d.ts
│ │ ├── .npmignore
│ │ ├── module.ts
│ │ ├── basic.component.ts
│ │ ├── basic.component.js.map
│ │ ├── module.js.map
│ │ ├── tsconfig-ngc.json
│ │ ├── .gitignore
│ │ ├── module.metadata.json
│ │ ├── module.js
│ │ ├── LICENSE
│ │ ├── basic.component.metadata.json
│ │ ├── basic.component.js
│ │ ├── package.json
│ │ └── README.md
│ ├── basic-html-no-css
│ ├── output-expected
│ │ ├── module.d.ts
│ │ ├── basic.component.d.ts
│ │ ├── .npmignore
│ │ ├── module.ts
│ │ ├── basic.component.ts
│ │ ├── basic.component.js.map
│ │ ├── module.js.map
│ │ ├── tsconfig-ngc.json
│ │ ├── .gitignore
│ │ ├── module.metadata.json
│ │ ├── module.js
│ │ ├── LICENSE
│ │ ├── basic.component.metadata.json
│ │ ├── basic.component.js
│ │ ├── package.json
│ │ └── README.md
│ └── input
│ │ ├── basic.component.html
│ │ ├── module.ts
│ │ └── basic.component.ts
│ ├── basic-html-basic-scss-and-css
│ ├── output-expected
│ │ ├── module.d.ts
│ │ ├── basic.component.d.ts
│ │ ├── .npmignore
│ │ ├── module.ts
│ │ ├── module.js.map
│ │ ├── basic.component.ts
│ │ ├── basic.component.js.map
│ │ ├── tsconfig-ngc.json
│ │ ├── .gitignore
│ │ ├── module.metadata.json
│ │ ├── module.js
│ │ ├── LICENSE
│ │ ├── basic.component.metadata.json
│ │ ├── basic.component.js
│ │ ├── package.json
│ │ └── README.md
│ └── input
│ │ ├── basic.component.css
│ │ ├── basic.component.html
│ │ ├── basic.component.scss
│ │ ├── module.ts
│ │ └── basic.component.ts
│ ├── basic-html-no-css-override-tsconfig
│ ├── output-expected
│ │ ├── module.d.ts
│ │ ├── basic.component.d.ts
│ │ ├── .npmignore
│ │ ├── module.ts
│ │ ├── basic.component.ts
│ │ ├── basic.component.js.map
│ │ ├── module.js.map
│ │ ├── tsconfig-ngc.json
│ │ ├── .gitignore
│ │ ├── module.metadata.json
│ │ ├── module.js
│ │ ├── LICENSE
│ │ ├── basic.component.metadata.json
│ │ ├── basic.component.js
│ │ ├── package.json
│ │ └── README.md
│ └── input
│ │ ├── override-tsconfig.json
│ │ ├── basic.component.html
│ │ ├── module.ts
│ │ └── basic.component.ts
│ └── scss-does-not-compile
│ └── input
│ ├── basic.component.html
│ ├── basic.component.scss
│ ├── module.ts
│ └── basic.component.ts
├── src
├── model
│ └── options.keys.ts
├── core
│ ├── tasks
│ │ ├── task.interface.ts
│ │ ├── delete-dest-folder.task.ts
│ │ ├── inline-html-css.helpers
│ │ │ ├── template.processor.ts
│ │ │ ├── sass.compiler.ts
│ │ │ └── style.processor.ts
│ │ ├── copy-files-to-outdir.task.ts
│ │ ├── ngc-compile.task.ts
│ │ ├── main.task.ts
│ │ ├── inline-html-css.task.ts
│ │ └── copy-tsconfig-ngc.task.ts
│ ├── services
│ │ └── logger.ts
│ ├── angular-library-builder.ts
│ └── angular-library-builder.spec.ts
└── bin
│ ├── options.values.ts
│ └── nglb.ts
├── tslint.json
├── .npmignore
├── .editorconfig
├── .nycrc
├── .travis.yml
├── tsconfig-ngc.json
├── tsconfig.json
├── .gitignore
├── LICENSE
├── package.json
└── README.md
/test/fixtures/allow-empty-scss-files/input/basic.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/input/basic.component.spec.ts:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/module.d.ts:
--------------------------------------------------------------------------------
1 | export declare class BasicModule {
2 | }
3 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/module.d.ts:
--------------------------------------------------------------------------------
1 | export declare class BasicModule {
2 | }
3 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/module.d.ts:
--------------------------------------------------------------------------------
1 | export declare class BasicModule {
2 | }
3 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/module.d.ts:
--------------------------------------------------------------------------------
1 | export declare class BasicModule {
2 | }
3 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/module.d.ts:
--------------------------------------------------------------------------------
1 | export declare class BasicModule {
2 | }
3 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/input/basic.component.css:
--------------------------------------------------------------------------------
1 | .normal-css {
2 | background-color: stuff;
3 | }
4 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/input/basic.component.html:
--------------------------------------------------------------------------------
1 | Angular {{ myAngularProperty }}
2 |
3 |
Stuff
4 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/input/override-tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "amd"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/input/basic.component.html:
--------------------------------------------------------------------------------
1 | Super Simple HTML
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/input/basic.component.html:
--------------------------------------------------------------------------------
1 | Angular {{ myAngularProperty }}
2 |
3 | Stuff
4 |
--------------------------------------------------------------------------------
/test/fixtures/scss-does-not-compile/input/basic.component.html:
--------------------------------------------------------------------------------
1 | Super Simple HTML
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/src/model/options.keys.ts:
--------------------------------------------------------------------------------
1 | export class OptionsKeys {
2 | static ROOT_DIR = 'rootDir';
3 | static OUT_DIR = 'outDir';
4 | static TSCONFIG = 'tsconfig';
5 | }
6 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/input/basic.component.html:
--------------------------------------------------------------------------------
1 | Angular {{ myAngularProperty }}
2 |
3 | Stuff
4 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/input/basic.component.html:
--------------------------------------------------------------------------------
1 | Super Simple HTML
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/input/basic.component.scss:
--------------------------------------------------------------------------------
1 | $my-color: red;
2 |
3 | .my-class {
4 | background-color: $my-color;
5 | position: sticky;
6 | }
7 |
--------------------------------------------------------------------------------
/src/core/tasks/task.interface.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Every task should implement this interface
3 | */
4 | export interface ITask {
5 | registerTask(argv: any, onError: () => void, dependencies: string[]): string;
6 | }
7 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "tslint-config-standard",
3 | "rules": {
4 | "semicolon": [
5 | true,
6 | "always"
7 | ],
8 | "space-before-function-paren": [true, "never"]
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/basic.component.d.ts:
--------------------------------------------------------------------------------
1 | import { OnInit } from '@angular/core';
2 | export declare class BasicComponent implements OnInit {
3 | constructor();
4 | ngOnInit(): void;
5 | }
6 |
--------------------------------------------------------------------------------
/test/fixtures/scss-does-not-compile/input/basic.component.scss:
--------------------------------------------------------------------------------
1 | $my-color: red;
2 |
3 | .my-class {
4 | background-color: $my-color;
5 | color: $variable-that-does-not-exist; // should break here!!!
6 | position: sticky;
7 | }
8 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # folders to ignore
2 | /src
3 | /node_modules
4 | /test
5 | /.nyc_output
6 | /coverage
7 |
8 | # ignore typescript files
9 | *.ts
10 |
11 | # ignore tsconfig.json and tslint
12 | tsconfig.json
13 | tslint.json
14 |
15 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/basic.component.d.ts:
--------------------------------------------------------------------------------
1 | import { OnInit } from '@angular/core';
2 | export declare class BasicComponent implements OnInit {
3 | constructor();
4 | ngOnInit(): void;
5 | }
6 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/basic.component.d.ts:
--------------------------------------------------------------------------------
1 | import { OnInit } from '@angular/core';
2 | export declare class BasicComponent implements OnInit {
3 | myAngularProperty: string;
4 | constructor();
5 | ngOnInit(): void;
6 | }
7 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/basic.component.d.ts:
--------------------------------------------------------------------------------
1 | import { OnInit } from '@angular/core';
2 | export declare class BasicComponent implements OnInit {
3 | myAngularProperty: string;
4 | constructor();
5 | ngOnInit(): void;
6 | }
7 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/basic.component.d.ts:
--------------------------------------------------------------------------------
1 | import { OnInit } from '@angular/core';
2 | export declare class BasicComponent implements OnInit {
3 | myAngularProperty: string;
4 | constructor();
5 | ngOnInit(): void;
6 | }
7 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/.npmignore:
--------------------------------------------------------------------------------
1 | # folders to ignore
2 | /src
3 | /node_modules
4 | /test
5 | /.nyc_output
6 | /coverage
7 |
8 | # ignore typescript files
9 | *.ts
10 |
11 | # ignore tsconfig.json and tslint
12 | tsconfig.json
13 | tslint.json
14 |
15 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/.npmignore:
--------------------------------------------------------------------------------
1 | # folders to ignore
2 | /src
3 | /node_modules
4 | /test
5 | /.nyc_output
6 | /coverage
7 |
8 | # ignore typescript files
9 | *.ts
10 |
11 | # ignore tsconfig.json and tslint
12 | tsconfig.json
13 | tslint.json
14 |
15 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/.npmignore:
--------------------------------------------------------------------------------
1 | # folders to ignore
2 | /src
3 | /node_modules
4 | /test
5 | /.nyc_output
6 | /coverage
7 |
8 | # ignore typescript files
9 | *.ts
10 |
11 | # ignore tsconfig.json and tslint
12 | tsconfig.json
13 | tslint.json
14 |
15 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/.npmignore:
--------------------------------------------------------------------------------
1 | # folders to ignore
2 | /src
3 | /node_modules
4 | /test
5 | /.nyc_output
6 | /coverage
7 |
8 | # ignore typescript files
9 | *.ts
10 |
11 | # ignore tsconfig.json and tslint
12 | tsconfig.json
13 | tslint.json
14 |
15 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/.npmignore:
--------------------------------------------------------------------------------
1 | # folders to ignore
2 | /src
3 | /node_modules
4 | /test
5 | /.nyc_output
6 | /coverage
7 |
8 | # ignore typescript files
9 | *.ts
10 |
11 | # ignore tsconfig.json and tslint
12 | tsconfig.json
13 | tslint.json
14 |
15 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/input/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/input/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/test/fixtures/scss-does-not-compile/input/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/input/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/input/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/input/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic.component';
4 |
5 | @NgModule({
6 | imports: [],
7 | exports: [BasicComponent],
8 | declarations: [BasicComponent],
9 | providers: [],
10 | })
11 | export class BasicModule { }
12 |
--------------------------------------------------------------------------------
/src/core/services/logger.ts:
--------------------------------------------------------------------------------
1 | import * as chalk from 'chalk';
2 |
3 | export class Logger {
4 | static success(text: string) {
5 | console.log(chalk.green(text));
6 | }
7 |
8 | static error(text: string) {
9 | console.log(chalk.red(text));
10 | }
11 |
12 | static warning(text: string) {
13 | console.log(chalk.yellow(text));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/.nycrc:
--------------------------------------------------------------------------------
1 | {
2 | "include": [
3 | "src/**/*.ts"
4 | ],
5 | "exclude": [
6 | "*/**/*.spec.ts"
7 | ],
8 | "extension": [
9 | ".ts"
10 | ],
11 | "require": [
12 | "ts-node/register"
13 | ],
14 | "reporter": [
15 | "text-summary",
16 | "html",
17 | "lcovonly"
18 | ],
19 | "sourceMap": true,
20 | "instrument": true
21 | }
22 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/input/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | templateUrl: 'basic.component.html',
6 | styleUrls: ['basic.component.scss']
7 | })
8 | export class BasicComponent implements OnInit {
9 | constructor() { }
10 |
11 | ngOnInit() { }
12 | }
13 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | template: `Super Simple HTML`,
6 | styles: [``]
7 | })
8 | export class BasicComponent implements OnInit {
9 | constructor() { }
10 |
11 | ngOnInit() { }
12 | }
13 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/input/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | templateUrl: 'basic.component.html'
6 | })
7 | export class BasicComponent implements OnInit {
8 | @Input() myAngularProperty: string;
9 |
10 | constructor() { }
11 |
12 | ngOnInit() { }
13 | }
14 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | cache:
3 | directories:
4 | - node_modules
5 | notifications:
6 | email: false
7 | node_js:
8 | - '8'
9 | - '7'
10 | - '6'
11 | before_script:
12 | - npm prune
13 | script:
14 | - npm test
15 | after_success:
16 | - npm run report-coverage
17 | - npm run semantic-release
18 | branches:
19 | except:
20 | - /^v\d+\.\d+\.\d+$/
21 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/input/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | templateUrl: 'basic.component.html'
6 | })
7 | export class BasicComponent implements OnInit {
8 | @Input() myAngularProperty: string;
9 |
10 | constructor() { }
11 |
12 | ngOnInit() { }
13 | }
14 |
--------------------------------------------------------------------------------
/test/fixtures/scss-does-not-compile/input/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | templateUrl: 'basic.component.html',
6 | styleUrls: ['basic.component.scss', 'basic.component.css']
7 | })
8 | export class BasicComponent implements OnInit {
9 | constructor() { }
10 |
11 | ngOnInit() { }
12 | }
13 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/input/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | templateUrl: 'basic.component.html'
6 | })
7 | export class BasicComponent implements OnInit {
8 | @Input() myAngularProperty: string;
9 |
10 | constructor() { }
11 |
12 | ngOnInit() { }
13 | }
14 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/input/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | templateUrl: 'basic.component.html',
6 | styleUrls: ['basic.component.scss', 'basic.component.css']
7 | })
8 | export class BasicComponent implements OnInit {
9 | constructor() { }
10 |
11 | ngOnInit() { }
12 | }
13 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | template: `Angular {{ myAngularProperty }}Stuff
`
6 | })
7 | export class BasicComponent implements OnInit {
8 | @Input() myAngularProperty: string;
9 |
10 | constructor() { }
11 |
12 | ngOnInit() { }
13 | }
14 |
--------------------------------------------------------------------------------
/tsconfig-ngc.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "es2015",
4 | "target": "es5",
5 | "emitDecoratorMetadata": true,
6 | "experimentalDecorators": true,
7 | "declaration": true,
8 | "sourceMap": true,
9 | "moduleResolution": "node",
10 | "lib": ["es2015", "dom"]
11 | },
12 | "angularCompilerOptions": {
13 | "strictMetadataEmit": true,
14 | "skipTemplateCodegen": true
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | template: `Angular {{ myAngularProperty }}Stuff
`
6 | })
7 | export class BasicComponent implements OnInit {
8 | @Input() myAngularProperty: string;
9 |
10 | constructor() { }
11 |
12 | ngOnInit() { }
13 | }
14 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | template: `Angular {{ myAngularProperty }}Stuff
`
6 | })
7 | export class BasicComponent implements OnInit {
8 | @Input() myAngularProperty: string;
9 |
10 | constructor() { }
11 |
12 | ngOnInit() { }
13 | }
14 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/basic.component.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"basic.component.js","sourceRoot":"","sources":["basic.component.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAU,KAAK,EAAE,MAAM,eAAe,CAAC;AAMzD,IAAa,cAAc;IAGzB;IAAgB,CAAC;IAEjB,iCAAQ,GAAR,cAAa,CAAC;IAChB,qBAAC;AAAD,CAAC,AAND,IAMC;AALU;IAAR,KAAK,EAAE;;yDAA2B;AADxB,cAAc;IAJ1B,SAAS,CAAC;QACT,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,6EAA2E;KACtF,CAAC;;GACW,cAAc,CAM1B;SANY,cAAc"}
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/module.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"module.js","sourceRoot":"","sources":["module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnD,IAAa,WAAW;IAAxB;IAA2B,CAAC;IAAD,kBAAC;AAAD,CAAC,AAA5B,IAA4B;AAAf,WAAW;IANvB,QAAQ,CAAC;QACR,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,CAAC,cAAc,CAAC;QACzB,YAAY,EAAE,CAAC,cAAc,CAAC;QAC9B,SAAS,EAAE,EAAE;KACd,CAAC;GACW,WAAW,CAAI;SAAf,WAAW"}
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/module.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"module.js","sourceRoot":"","sources":["module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnD,IAAa,WAAW;IAAxB;IAA2B,CAAC;IAAD,kBAAC;AAAD,CAAC,AAA5B,IAA4B;AAAf,WAAW;IANvB,QAAQ,CAAC;QACR,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,CAAC,cAAc,CAAC;QACzB,YAAY,EAAE,CAAC,cAAc,CAAC;QAC9B,SAAS,EAAE,EAAE;KACd,CAAC;GACW,WAAW,CAAI;SAAf,WAAW"}
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/module.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"module.js","sourceRoot":"","sources":["module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnD,IAAa,WAAW;IAAxB;IAA2B,CAAC;IAAD,kBAAC;AAAD,CAAC,AAA5B,IAA4B;AAAf,WAAW;IANvB,QAAQ,CAAC;QACR,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,CAAC,cAAc,CAAC;QACzB,YAAY,EAAE,CAAC,cAAc,CAAC;QAC9B,SAAS,EAAE,EAAE;KACd,CAAC;GACW,WAAW,CAAI;SAAf,WAAW"}
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/basic.component.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"basic.component.js","sourceRoot":"","sources":["basic.component.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAU,KAAK,EAAE,MAAM,eAAe,CAAC;AAMzD,IAAa,cAAc;IAGzB;IAAgB,CAAC;IAEjB,iCAAQ,GAAR,cAAa,CAAC;IAChB,qBAAC;AAAD,CAAC,AAND,IAMC;AALU;IAAR,KAAK,EAAE;;yDAA2B;AADxB,cAAc;IAJ1B,SAAS,CAAC;QACT,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,6EAA2E;KACtF,CAAC;;GACW,cAAc,CAM1B;SANY,cAAc"}
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/basic.component.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"basic.component.js","sourceRoot":"","sources":["basic.component.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAU,KAAK,EAAE,MAAM,eAAe,CAAC;AAMzD,IAAa,cAAc;IAGzB;IAAgB,CAAC;IAEjB,iCAAQ,GAAR,cAAa,CAAC;IAChB,qBAAC;AAAD,CAAC,AAND,IAMC;AALU;IAAR,KAAK,EAAE;;yDAA2B;AADxB,cAAc;IAJ1B,SAAS,CAAC;QACT,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,6EAA2E;KACtF,CAAC;;GACW,cAAc,CAM1B;SANY,cAAc"}
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/module.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"module.js","sourceRoot":"","sources":["module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnD,IAAa,WAAW;IAAxB;IAA2B,CAAC;IAAD,kBAAC;AAAD,CAAC,AAA5B,IAA4B;AAAf,WAAW;IANvB,QAAQ,CAAC;QACR,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,CAAC,cAAc,CAAC;QACzB,YAAY,EAAE,CAAC,cAAc,CAAC;QAC9B,SAAS,EAAE,EAAE;KACd,CAAC;GACW,WAAW,CAAI;SAAf,WAAW"}
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/module.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"module.js","sourceRoot":"","sources":["module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnD,IAAa,WAAW;IAAxB;IAA2B,CAAC;IAAD,kBAAC;AAAD,CAAC,AAA5B,IAA4B;AAAf,WAAW;IANvB,QAAQ,CAAC;QACR,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,CAAC,cAAc,CAAC;QACzB,YAAY,EAAE,CAAC,cAAc,CAAC;QAC9B,SAAS,EAAE,EAAE;KACd,CAAC;GACW,WAAW,CAAI;SAAf,WAAW"}
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/basic.component.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"basic.component.js","sourceRoot":"","sources":["basic.component.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,eAAe,CAAC;AAQlD,IAAa,cAAc;IACzB;IAAgB,CAAC;IAEjB,iCAAQ,GAAR,cAAa,CAAC;IAChB,qBAAC;AAAD,CAAC,AAJD,IAIC;AAJY,cAAc;IAN1B,SAAS,CAAC;QACT,QAAQ,EAAE,MAAM,CAAC,EAAE;QACnB,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,yCAAyC;QACnD,MAAM,EAAE,CAAC,EAAE,CAAC;KACb,CAAC;;GACW,cAAc,CAI1B;SAJY,cAAc"}
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'selector',
5 | template: `Super Simple HTML`,
6 | styles: [`.my-class{background-color:red;position:-webkit-sticky;position:sticky}.normal-css{background-color:stuff}`]
7 | })
8 | export class BasicComponent implements OnInit {
9 | constructor() { }
10 |
11 | ngOnInit() { }
12 | }
13 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/basic.component.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"basic.component.js","sourceRoot":"","sources":["basic.component.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,eAAe,CAAC;AAQlD,IAAa,cAAc;IACzB;IAAgB,CAAC;IAEjB,iCAAQ,GAAR,cAAa,CAAC;IAChB,qBAAC;AAAD,CAAC,AAJD,IAIC;AAJY,cAAc;IAN1B,SAAS,CAAC;QACT,QAAQ,EAAE,MAAM,CAAC,EAAE;QACnB,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,yCAAyC;QACnD,MAAM,EAAE,CAAC,4GAA4G,CAAC;KACvH,CAAC;;GACW,cAAc,CAI1B;SAJY,cAAc"}
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/tsconfig-ngc.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "noImplicitAny": true,
4 | "module": "es2015",
5 | "target": "es5",
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "declaration": true,
9 | "moduleResolution": "node",
10 | "noUnusedLocals": true,
11 | "lib": ["es2015", "dom"]
12 | },
13 | "angularCompilerOptions": {
14 | "strictMetadataEmit": true,
15 | "skipTemplateCodegen": true
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/tsconfig-ngc.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "noImplicitAny": true,
4 | "module": "es2015",
5 | "target": "es5",
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "declaration": true,
9 | "moduleResolution": "node",
10 | "noUnusedLocals": true,
11 | "lib": ["es2015", "dom"]
12 | },
13 | "angularCompilerOptions": {
14 | "strictMetadataEmit": true,
15 | "skipTemplateCodegen": true
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/tsconfig-ngc.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "noImplicitAny": true,
4 | "module": "es2015",
5 | "target": "es5",
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "declaration": true,
9 | "moduleResolution": "node",
10 | "noUnusedLocals": true,
11 | "lib": ["es2015", "dom"]
12 | },
13 | "angularCompilerOptions": {
14 | "strictMetadataEmit": true,
15 | "skipTemplateCodegen": true
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/tsconfig-ngc.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "noImplicitAny": true,
4 | "module": "amd",
5 | "target": "es5",
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "declaration": true,
9 | "moduleResolution": "node",
10 | "noUnusedLocals": true,
11 | "lib": ["es2015", "dom"]
12 | },
13 | "angularCompilerOptions": {
14 | "strictMetadataEmit": true,
15 | "skipTemplateCodegen": true
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/tsconfig-ngc.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "noImplicitAny": true,
4 | "module": "es2015",
5 | "target": "es5",
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "declaration": true,
9 | "moduleResolution": "node",
10 | "noUnusedLocals": true,
11 | "lib": ["es2015", "dom"]
12 | },
13 | "angularCompilerOptions": {
14 | "strictMetadataEmit": true,
15 | "skipTemplateCodegen": true
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/core/tasks/delete-dest-folder.task.ts:
--------------------------------------------------------------------------------
1 | import * as del from 'del';
2 | import { ITask } from './task.interface';
3 | import { OptionsKeys } from '../../model/options.keys';
4 |
5 | const gulp = require('gulp');
6 |
7 | /**
8 | * Delete our dist folder before every run
9 | */
10 | export class DeleteDestFolderTask implements ITask {
11 |
12 | /**
13 | * Registring the task
14 | */
15 | registerTask(argv: any, onError: () => void, dependencies: string[] = []): string {
16 | const taskName = 'delete-dest-folder-task';
17 |
18 | gulp.task(taskName, dependencies ,() => {
19 | return del([argv[OptionsKeys.OUT_DIR]]);
20 | });
21 |
22 | return taskName;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/bin/options.values.ts:
--------------------------------------------------------------------------------
1 | import { Options } from 'yargs';
2 | import { OptionsKeys } from '../model/options.keys';
3 |
4 | export const optionsValues: { [key: string]: Options } = {
5 | [OptionsKeys.ROOT_DIR] : {
6 | describe: 'Specifies the root directory of input files',
7 | demand: true,
8 | type: 'string'
9 | },
10 | [OptionsKeys.OUT_DIR]: {
11 | describe: 'Redirect output structure to the directory',
12 | demand: true,
13 | type: 'string'
14 | },
15 | [OptionsKeys.TSCONFIG]: {
16 | describe: 'Extends/Overrides the default angular-library-builder tsconfig-ngc.json file used by ngc (angular compiler)',
17 | demand: false,
18 | type: 'string'
19 | }
20 | };
21 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "rootDir": "./src",
4 | "outDir": "./",
5 | "declaration": false,
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "module": "commonjs",
9 | "moduleResolution": "node",
10 | "sourceMap": true,
11 | "target": "es2016",
12 | "lib": [
13 | "es2016"
14 | ],
15 | "importHelpers": true,
16 | "pretty": true,
17 | "strictNullChecks": true,
18 | "forceConsistentCasingInFileNames": true,
19 | "noFallthroughCasesInSwitch": true,
20 | "noImplicitAny": true,
21 | "noImplicitReturns": true,
22 | "noImplicitThis": true,
23 | "noUnusedLocals": true
24 | },
25 | "exclude": [
26 | "node_modules",
27 | "test/fixtures"
28 | ]
29 | }
30 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /tmp
5 | /core
6 | /model
7 | /bin
8 |
9 | # dependencies
10 | /node_modules
11 |
12 | # IDE - VSCode
13 | .vscode/*
14 |
15 | # misc
16 | /.sass-cache
17 | /connect.lock
18 | /coverage/*
19 | /libpeerconnection.log
20 | npm-debug.log
21 | testem.log
22 | /typings
23 | .nyc_output
24 |
25 | #System Files
26 | .DS_Store
27 | Thumbs.db
28 |
29 | #ignore ignore outputs after tests
30 | /test/fixtures/**/output
31 |
32 | #ignore everything except typescript
33 | *.js
34 | *.js.map
35 | *.d.ts
36 | *.metadata.json
37 |
38 | #apart from test output-expected
39 | !/test/fixtures/**/output-expected/*.js
40 | !/test/fixtures/**/output-expected/*.js.map
41 | !/test/fixtures/**/output-expected/*.d.ts
42 | !/test/fixtures/**/output-expected/*.metadata.json
43 |
--------------------------------------------------------------------------------
/src/bin/nglb.ts:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | import * as yargs from 'yargs';
4 | import { optionsValues } from './options.values';
5 | import { AngularLibraryBuilder } from '../core/angular-library-builder';
6 |
7 | const argv = yargs
8 | // help
9 | .help('help')
10 | .alias('help', 'h')
11 |
12 | // version
13 | .version()
14 | .alias('version', 'v')
15 |
16 | // usage
17 | .usage('Usage: $0 [options]')
18 | .example('Example: $0 --rootDir src/lib --outDir dist', '[root directory is src/lib and the output directory is dist]')
19 |
20 | // options
21 | .options(optionsValues)
22 |
23 | // only accept known parameters
24 | .strict()
25 |
26 | // epilog, aka, footer of the helper command
27 | .epilog('Angular (2+) Library Builder')
28 | .argv;
29 |
30 | const builder = new AngularLibraryBuilder(argv);
31 | builder.buildLibrary();
32 |
--------------------------------------------------------------------------------
/src/core/tasks/inline-html-css.helpers/template.processor.ts:
--------------------------------------------------------------------------------
1 | import { minify } from 'html-minifier';
2 | import { Logger } from '../../services/logger';
3 |
4 | /**
5 | * Using html-minifier in order to minify our HTML
6 | * Some conservative rules used in order to preserve angular functionality
7 | *
8 | */
9 | export function templateProcessor(path: string, ext: string, file: string, cb: Function) {
10 | try {
11 | var minifiedFile = minify(file, {
12 | collapseWhitespace: true,
13 | caseSensitive: true,
14 | removeComments: true,
15 | removeRedundantAttributes: true,
16 | keepClosingSlash: true
17 | });
18 | cb(null, minifiedFile);
19 | }
20 | catch (err) {
21 | Logger.error('Problem with html-minifier. Please create an issue https://github.com/bmvantunes/angular-library-builder');
22 | cb(err);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/core/tasks/copy-files-to-outdir.task.ts:
--------------------------------------------------------------------------------
1 | import { ITask } from './task.interface';
2 | import { OptionsKeys } from '../../model/options.keys';
3 | import * as plumber from 'gulp-plumber';
4 |
5 | const gulp = require('gulp');
6 |
7 | /**
8 | * Copy markdown files and package.json to outDir folder
9 | */
10 | export class CopyFilesToOutdirTask implements ITask {
11 |
12 | /**
13 | * Registring the task
14 | */
15 | registerTask(argv: any, onError: () => void, dependencies: string[] = []): string {
16 | const taskName = 'copy-files-to-outdir-task';
17 | const filesToCopy = ['package.json', '*.md', '.gitignore', '.npmignore', 'LICENSE'];
18 |
19 | gulp.task(taskName, dependencies, () => {
20 | return gulp.src(filesToCopy)
21 | .pipe(plumber(onError))
22 | .pipe(gulp.dest(argv[OptionsKeys.OUT_DIR]));
23 | });
24 |
25 | return taskName;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /tmp
5 | /core
6 | /model
7 | /bin
8 |
9 | # dependencies
10 | /node_modules
11 |
12 | # IDE - VSCode
13 | .vscode/*
14 |
15 | # misc
16 | /.sass-cache
17 | /connect.lock
18 | /coverage/*
19 | /libpeerconnection.log
20 | npm-debug.log
21 | testem.log
22 | /typings
23 | .nyc_output
24 |
25 | #System Files
26 | .DS_Store
27 | Thumbs.db
28 |
29 | #ignore ignore outputs after tests
30 | /test/fixtures/**/output
31 |
32 | #ignore everything except typescript
33 | *.js
34 | *.js.map
35 | *.d.ts
36 | *.metadata.json
37 |
38 | #apart from test output-expected
39 | !/test/fixtures/**/output-expected/*.js
40 | !/test/fixtures/**/output-expected/*.js.map
41 | !/test/fixtures/**/output-expected/*.d.ts
42 | !/test/fixtures/**/output-expected/*.metadata.json
43 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /tmp
5 | /core
6 | /model
7 | /bin
8 |
9 | # dependencies
10 | /node_modules
11 |
12 | # IDE - VSCode
13 | .vscode/*
14 |
15 | # misc
16 | /.sass-cache
17 | /connect.lock
18 | /coverage/*
19 | /libpeerconnection.log
20 | npm-debug.log
21 | testem.log
22 | /typings
23 | .nyc_output
24 |
25 | #System Files
26 | .DS_Store
27 | Thumbs.db
28 |
29 | #ignore ignore outputs after tests
30 | /test/fixtures/**/output
31 |
32 | #ignore everything except typescript
33 | *.js
34 | *.js.map
35 | *.d.ts
36 | *.metadata.json
37 |
38 | #apart from test output-expected
39 | !/test/fixtures/**/output-expected/*.js
40 | !/test/fixtures/**/output-expected/*.js.map
41 | !/test/fixtures/**/output-expected/*.d.ts
42 | !/test/fixtures/**/output-expected/*.metadata.json
43 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/module.metadata.json:
--------------------------------------------------------------------------------
1 | [{"__symbolic":"module","version":3,"metadata":{"BasicModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[],"exports":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"declarations":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"providers":[]}]}]}}},{"__symbolic":"module","version":1,"metadata":{"BasicModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[],"exports":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"declarations":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"providers":[]}]}]}}}]
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/module.metadata.json:
--------------------------------------------------------------------------------
1 | [{"__symbolic":"module","version":3,"metadata":{"BasicModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[],"exports":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"declarations":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"providers":[]}]}]}}},{"__symbolic":"module","version":1,"metadata":{"BasicModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[],"exports":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"declarations":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"providers":[]}]}]}}}]
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /tmp
5 | /core
6 | /model
7 | /bin
8 |
9 | # dependencies
10 | /node_modules
11 |
12 | # IDE - VSCode
13 | .vscode/*
14 |
15 | # misc
16 | /.sass-cache
17 | /connect.lock
18 | /coverage/*
19 | /libpeerconnection.log
20 | npm-debug.log
21 | testem.log
22 | /typings
23 | .nyc_output
24 |
25 | #System Files
26 | .DS_Store
27 | Thumbs.db
28 |
29 | #ignore ignore outputs after tests
30 | /test/fixtures/**/output
31 |
32 | #ignore everything except typescript
33 | *.js
34 | *.js.map
35 | *.d.ts
36 | *.metadata.json
37 |
38 | #apart from test output-expected
39 | !/test/fixtures/**/output-expected/*.js
40 | !/test/fixtures/**/output-expected/*.js.map
41 | !/test/fixtures/**/output-expected/*.d.ts
42 | !/test/fixtures/**/output-expected/*.metadata.json
43 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /tmp
5 | /core
6 | /model
7 | /bin
8 |
9 | # dependencies
10 | /node_modules
11 |
12 | # IDE - VSCode
13 | .vscode/*
14 |
15 | # misc
16 | /.sass-cache
17 | /connect.lock
18 | /coverage/*
19 | /libpeerconnection.log
20 | npm-debug.log
21 | testem.log
22 | /typings
23 | .nyc_output
24 |
25 | #System Files
26 | .DS_Store
27 | Thumbs.db
28 |
29 | #ignore ignore outputs after tests
30 | /test/fixtures/**/output
31 |
32 | #ignore everything except typescript
33 | *.js
34 | *.js.map
35 | *.d.ts
36 | *.metadata.json
37 |
38 | #apart from test output-expected
39 | !/test/fixtures/**/output-expected/*.js
40 | !/test/fixtures/**/output-expected/*.js.map
41 | !/test/fixtures/**/output-expected/*.d.ts
42 | !/test/fixtures/**/output-expected/*.metadata.json
43 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /tmp
5 | /core
6 | /model
7 | /bin
8 |
9 | # dependencies
10 | /node_modules
11 |
12 | # IDE - VSCode
13 | .vscode/*
14 |
15 | # misc
16 | /.sass-cache
17 | /connect.lock
18 | /coverage/*
19 | /libpeerconnection.log
20 | npm-debug.log
21 | testem.log
22 | /typings
23 | .nyc_output
24 |
25 | #System Files
26 | .DS_Store
27 | Thumbs.db
28 |
29 | #ignore ignore outputs after tests
30 | /test/fixtures/**/output
31 |
32 | #ignore everything except typescript
33 | *.js
34 | *.js.map
35 | *.d.ts
36 | *.metadata.json
37 |
38 | #apart from test output-expected
39 | !/test/fixtures/**/output-expected/*.js
40 | !/test/fixtures/**/output-expected/*.js.map
41 | !/test/fixtures/**/output-expected/*.d.ts
42 | !/test/fixtures/**/output-expected/*.metadata.json
43 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/module.metadata.json:
--------------------------------------------------------------------------------
1 | [{"__symbolic":"module","version":3,"metadata":{"BasicModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[],"exports":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"declarations":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"providers":[]}]}]}}},{"__symbolic":"module","version":1,"metadata":{"BasicModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[],"exports":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"declarations":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"providers":[]}]}]}}}]
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/module.metadata.json:
--------------------------------------------------------------------------------
1 | [{"__symbolic":"module","version":3,"metadata":{"BasicModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[],"exports":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"declarations":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"providers":[]}]}]}}},{"__symbolic":"module","version":1,"metadata":{"BasicModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[],"exports":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"declarations":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"providers":[]}]}]}}}]
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/module.metadata.json:
--------------------------------------------------------------------------------
1 | [{"__symbolic":"module","version":3,"metadata":{"BasicModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[],"exports":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"declarations":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"providers":[]}]}]}}},{"__symbolic":"module","version":1,"metadata":{"BasicModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[],"exports":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"declarations":[{"__symbolic":"reference","module":"./basic.component","name":"BasicComponent"}],"providers":[]}]}]}}}]
--------------------------------------------------------------------------------
/src/core/tasks/ngc-compile.task.ts:
--------------------------------------------------------------------------------
1 | import { ITask } from './task.interface';
2 | import { OptionsKeys } from '../../model/options.keys';
3 | import { main } from '@angular/compiler-cli/src/main';
4 | import { Logger } from '../services/logger';
5 |
6 | const gulp = require('gulp');
7 |
8 | /**
9 | * Compile our typescript files with ngc
10 | */
11 | export class NgcCompileTask implements ITask {
12 |
13 | /**
14 | * Registring the task
15 | */
16 | registerTask(argv: any, onError: () => void, dependencies: string[] = []): string {
17 | const taskName = 'compile-ngc';
18 | const ngcArguments = { p: `${argv[OptionsKeys.OUT_DIR]}/tsconfig-ngc.json` };
19 |
20 | gulp.task(taskName, dependencies, (done: Function) => {
21 | main(ngcArguments, Logger.error).then((exitCode: number) => {
22 | if (exitCode === 0) {
23 | done();
24 | } else {
25 | onError();
26 | }
27 | });
28 | });
29 |
30 | return taskName;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/basic.component.metadata.json:
--------------------------------------------------------------------------------
1 | [{"__symbolic":"module","version":3,"metadata":{"BasicComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"moduleId":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"module"},"member":"id"},"selector":"selector","template":"Super Simple HTML","styles":[""]}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"BasicComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"moduleId":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"module"},"member":"id"},"selector":"selector","template":"Super Simple HTML","styles":[""]}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}}]
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/module.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | import { NgModule } from '@angular/core';
8 | import { BasicComponent } from './basic.component';
9 | var BasicModule = (function () {
10 | function BasicModule() {
11 | }
12 | return BasicModule;
13 | }());
14 | BasicModule = __decorate([
15 | NgModule({
16 | imports: [],
17 | exports: [BasicComponent],
18 | declarations: [BasicComponent],
19 | providers: [],
20 | })
21 | ], BasicModule);
22 | export { BasicModule };
23 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/module.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | import { NgModule } from '@angular/core';
8 | import { BasicComponent } from './basic.component';
9 | var BasicModule = (function () {
10 | function BasicModule() {
11 | }
12 | return BasicModule;
13 | }());
14 | BasicModule = __decorate([
15 | NgModule({
16 | imports: [],
17 | exports: [BasicComponent],
18 | declarations: [BasicComponent],
19 | providers: [],
20 | })
21 | ], BasicModule);
22 | export { BasicModule };
23 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/module.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | import { NgModule } from '@angular/core';
8 | import { BasicComponent } from './basic.component';
9 | var BasicModule = (function () {
10 | function BasicModule() {
11 | }
12 | return BasicModule;
13 | }());
14 | BasicModule = __decorate([
15 | NgModule({
16 | imports: [],
17 | exports: [BasicComponent],
18 | declarations: [BasicComponent],
19 | providers: [],
20 | })
21 | ], BasicModule);
22 | export { BasicModule };
23 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/module.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | import { NgModule } from '@angular/core';
8 | import { BasicComponent } from './basic.component';
9 | var BasicModule = (function () {
10 | function BasicModule() {
11 | }
12 | return BasicModule;
13 | }());
14 | BasicModule = __decorate([
15 | NgModule({
16 | imports: [],
17 | exports: [BasicComponent],
18 | declarations: [BasicComponent],
19 | providers: [],
20 | })
21 | ], BasicModule);
22 | export { BasicModule };
23 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/module.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | import { NgModule } from '@angular/core';
8 | import { BasicComponent } from './basic.component';
9 | var BasicModule = (function () {
10 | function BasicModule() {
11 | }
12 | return BasicModule;
13 | }());
14 | BasicModule = __decorate([
15 | NgModule({
16 | imports: [],
17 | exports: [BasicComponent],
18 | declarations: [BasicComponent],
19 | providers: [],
20 | })
21 | ], BasicModule);
22 | export { BasicModule };
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Bruno Antunes
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Bruno Antunes
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Bruno Antunes
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Bruno Antunes
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/core/angular-library-builder.ts:
--------------------------------------------------------------------------------
1 | import { MainTask } from './tasks/main.task';
2 | import { Logger } from './services/logger';
3 |
4 | const gulp = require('gulp');
5 |
6 | /**
7 | * This is just an abstraction on top of gulp
8 | */
9 | export class AngularLibraryBuilder {
10 | private mainTask: MainTask;
11 |
12 | constructor(private args: { [key: string]: string }) {
13 | this.mainTask = new MainTask();
14 | }
15 |
16 | /**
17 | * Invoke mainTask to register all the other tasks in gulp api
18 | * Then run the main task with gulp.
19 | */
20 | buildLibrary() {
21 | const taskName = this.mainTask.registerAllTasks(this.args, this.onError);
22 | gulp.start(taskName, this.onSuccess);
23 | }
24 |
25 | /**
26 | * When everything finishes with success this method should be called!
27 | */
28 | onSuccess() {
29 | Logger.success('Your library was successfully built! Congratulations!');
30 | process.exit(0);
31 | }
32 |
33 | /**
34 | * When something wrong happens this method should be called!
35 | */
36 | onError() {
37 | Logger.warning('\nUnfortunately we were not able to build your library! :( \n');
38 | process.exit(-1);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Bruno Antunes
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Bruno Antunes
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/basic.component.metadata.json:
--------------------------------------------------------------------------------
1 | [{"__symbolic":"module","version":3,"metadata":{"BasicComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"selector","template":"Angular {{ myAngularProperty }}Stuff
"}]}],"members":{"myAngularProperty":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"BasicComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"selector","template":"Angular {{ myAngularProperty }}Stuff
"}]}],"members":{"myAngularProperty":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}}]
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/basic.component.metadata.json:
--------------------------------------------------------------------------------
1 | [{"__symbolic":"module","version":3,"metadata":{"BasicComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"selector","template":"Angular {{ myAngularProperty }}Stuff
"}]}],"members":{"myAngularProperty":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"BasicComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"selector","template":"Angular {{ myAngularProperty }}Stuff
"}]}],"members":{"myAngularProperty":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}}]
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/basic.component.metadata.json:
--------------------------------------------------------------------------------
1 | [{"__symbolic":"module","version":3,"metadata":{"BasicComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"selector","template":"Angular {{ myAngularProperty }}Stuff
"}]}],"members":{"myAngularProperty":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"BasicComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"selector","template":"Angular {{ myAngularProperty }}Stuff
"}]}],"members":{"myAngularProperty":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}}]
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/basic.component.metadata.json:
--------------------------------------------------------------------------------
1 | [{"__symbolic":"module","version":3,"metadata":{"BasicComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"moduleId":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"module"},"member":"id"},"selector":"selector","template":"Super Simple HTML","styles":[".my-class{background-color:red;position:-webkit-sticky;position:sticky}.normal-css{background-color:stuff}"]}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"BasicComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"moduleId":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"module"},"member":"id"},"selector":"selector","template":"Super Simple HTML","styles":[".my-class{background-color:red;position:-webkit-sticky;position:sticky}.normal-css{background-color:stuff}"]}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"ngOnInit":[{"__symbolic":"method"}]}}}}]
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/basic.component.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | var __metadata = (this && this.__metadata) || function (k, v) {
8 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9 | };
10 | import { Component } from '@angular/core';
11 | var BasicComponent = (function () {
12 | function BasicComponent() {
13 | }
14 | BasicComponent.prototype.ngOnInit = function () { };
15 | return BasicComponent;
16 | }());
17 | BasicComponent = __decorate([
18 | Component({
19 | selector: 'selector',
20 | template: "Super Simple HTML",
21 | styles: [""]
22 | }),
23 | __metadata("design:paramtypes", [])
24 | ], BasicComponent);
25 | export { BasicComponent };
26 |
--------------------------------------------------------------------------------
/src/core/tasks/inline-html-css.helpers/sass.compiler.ts:
--------------------------------------------------------------------------------
1 | import { render, Result } from 'node-sass';
2 | import { Logger } from '../../services/logger';
3 |
4 | /**
5 | * We use node-sass to compile our scss/sass
6 | * If we get an error we call our callback with the error
7 | * If we don't have any errors, we just call onSucess with
8 | * the resulting css and the initial callback
9 | */
10 | export function compileSass(path: string, ext: any, file: string, callback: Function, onSuccess: Function) {
11 | render({
12 | file: path,
13 | outputStyle: 'compressed',
14 | importer: importer
15 | }, (error: any, result: Result) => {
16 |
17 | if (error) { // Ups problems...
18 | Logger.error(error.formatted);
19 | callback(error);
20 | }
21 | else { // everything went well :)
22 | onSuccess(result.css, callback);
23 | }
24 |
25 | });
26 | }
27 |
28 | /**
29 | * When the compiler tries to import something like @import "~something/something"
30 | * it will actually get the file /your/project/path/node_modules/something/something.scss
31 | * This only happens if we type ~ in the beginning of the import path.
32 | * Otherwise it would work as normally node-sass works:
33 | * node-sass will try to use something like ./something/something.scss
34 | */
35 | function importer(url: string, prev: any, done: Function) {
36 | const newPath = url.replace(/^~/, `${process.cwd()}/node_modules/`);
37 | done({ file: newPath });
38 | }
39 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/basic.component.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | var __metadata = (this && this.__metadata) || function (k, v) {
8 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9 | };
10 | import { Component } from '@angular/core';
11 | var BasicComponent = (function () {
12 | function BasicComponent() {
13 | }
14 | BasicComponent.prototype.ngOnInit = function () { };
15 | return BasicComponent;
16 | }());
17 | BasicComponent = __decorate([
18 | Component({
19 | selector: 'selector',
20 | template: "Super Simple HTML",
21 | styles: [".my-class{background-color:red;position:-webkit-sticky;position:sticky}.normal-css{background-color:stuff}"]
22 | }),
23 | __metadata("design:paramtypes", [])
24 | ], BasicComponent);
25 | export { BasicComponent };
26 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/basic.component.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | var __metadata = (this && this.__metadata) || function (k, v) {
8 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9 | };
10 | import { Component, Input } from '@angular/core';
11 | var BasicComponent = (function () {
12 | function BasicComponent() {
13 | }
14 | BasicComponent.prototype.ngOnInit = function () { };
15 | return BasicComponent;
16 | }());
17 | __decorate([
18 | Input(),
19 | __metadata("design:type", String)
20 | ], BasicComponent.prototype, "myAngularProperty", void 0);
21 | BasicComponent = __decorate([
22 | Component({
23 | selector: 'selector',
24 | template: "Angular {{ myAngularProperty }}Stuff
"
25 | }),
26 | __metadata("design:paramtypes", [])
27 | ], BasicComponent);
28 | export { BasicComponent };
29 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/basic.component.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | var __metadata = (this && this.__metadata) || function (k, v) {
8 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9 | };
10 | import { Component, Input } from '@angular/core';
11 | var BasicComponent = (function () {
12 | function BasicComponent() {
13 | }
14 | BasicComponent.prototype.ngOnInit = function () { };
15 | return BasicComponent;
16 | }());
17 | __decorate([
18 | Input(),
19 | __metadata("design:type", String)
20 | ], BasicComponent.prototype, "myAngularProperty", void 0);
21 | BasicComponent = __decorate([
22 | Component({
23 | selector: 'selector',
24 | template: "Angular {{ myAngularProperty }}Stuff
"
25 | }),
26 | __metadata("design:paramtypes", [])
27 | ], BasicComponent);
28 | export { BasicComponent };
29 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/basic.component.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | var __metadata = (this && this.__metadata) || function (k, v) {
8 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9 | };
10 | import { Component, Input } from '@angular/core';
11 | var BasicComponent = (function () {
12 | function BasicComponent() {
13 | }
14 | BasicComponent.prototype.ngOnInit = function () { };
15 | return BasicComponent;
16 | }());
17 | __decorate([
18 | Input(),
19 | __metadata("design:type", String)
20 | ], BasicComponent.prototype, "myAngularProperty", void 0);
21 | BasicComponent = __decorate([
22 | Component({
23 | selector: 'selector',
24 | template: "Angular {{ myAngularProperty }}Stuff
"
25 | }),
26 | __metadata("design:paramtypes", [])
27 | ], BasicComponent);
28 | export { BasicComponent };
29 |
--------------------------------------------------------------------------------
/src/core/tasks/inline-html-css.helpers/style.processor.ts:
--------------------------------------------------------------------------------
1 | import { compileSass } from './sass.compiler';
2 | import * as postcss from 'postcss';
3 | import { Logger } from '../../services/logger';
4 |
5 | const csso = require('csso');
6 | const autoprefixer = require('autoprefixer');
7 |
8 | /**
9 | * If our file is .scss or .sass we first compile it using node-sass, then
10 | * we just call applyOptimization with the compile css.
11 | * If it is a plain css file, we just call applyOptimization
12 | */
13 | export function styleProcessor(path: string, ext: any, file: string, cb: Function) {
14 | if (['.scss', '.sass'].indexOf(ext[0]) >= 0) {
15 | compileSass(path, ext, file, cb, applyOptimization);
16 | } else {
17 | applyOptimization(file, cb);
18 | }
19 | }
20 |
21 | /**
22 | * Apply optimizations to our code
23 | * Add autoprefixer:
24 | * - if we have something like position: sticky;
25 | * - with autoprefixer the end result is something like:
26 | * - position:-webkit-sticky; position:sticky;
27 | *
28 | * We also minify with CSSO that is a really powerful minifier
29 | * - sometimes too greedy
30 | */
31 | function applyOptimization(css = '', cb: Function) {
32 | try {
33 | const autoprefixed = postcss([autoprefixer]).process(css).css;
34 | const minified = csso.minify(autoprefixed).css;
35 | cb(null, minified);
36 | }
37 | catch (err) {
38 | Logger.error('Problem with autoprefixer/csso. Please create an issue https://github.com/bmvantunes/angular-library-builder');
39 | cb(err);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/core/tasks/main.task.ts:
--------------------------------------------------------------------------------
1 | import { DeleteDestFolderTask } from './delete-dest-folder.task';
2 | import { InlineHtmlCssTask } from './inline-html-css.task';
3 | import { NgcCompileTask } from './ngc-compile.task';
4 | import { CopyTsconfigNgcTask } from './copy-tsconfig-ngc.task';
5 | import { CopyFilesToOutdirTask } from './copy-files-to-outdir.task';
6 |
7 | const gulp = require('gulp');
8 |
9 | /**
10 | * Main taks that manages all dependencies between other tasks
11 | */
12 | export class MainTask {
13 | private deleteTask: DeleteDestFolderTask;
14 | private inlineTask: InlineHtmlCssTask;
15 | private copyTsconfigTask: CopyTsconfigNgcTask;
16 | private ngcTask: NgcCompileTask;
17 | private copyFilesOutdirTask: CopyFilesToOutdirTask;
18 |
19 | constructor() {
20 | this.deleteTask = new DeleteDestFolderTask();
21 | this.inlineTask = new InlineHtmlCssTask();
22 | this.copyTsconfigTask = new CopyTsconfigNgcTask();
23 | this.ngcTask = new NgcCompileTask();
24 | this.copyFilesOutdirTask = new CopyFilesToOutdirTask();
25 | }
26 |
27 | registerAllTasks(argv: any, onError: () => void) {
28 | const deleteTaskName = this.deleteTask.registerTask(argv, onError);
29 | const inlineTaskName = this.inlineTask.registerTask(argv, onError, [deleteTaskName]);
30 | const copyTsconfigTaskName = this.copyTsconfigTask.registerTask(argv, onError, [inlineTaskName]);
31 | const ngcTaskName = this.ngcTask.registerTask(argv, onError, [copyTsconfigTaskName]);
32 | const copyFilesOutdirTaskName = this.copyFilesOutdirTask.registerTask(argv, onError, [ngcTaskName]);
33 |
34 | const taskName = 'main-task';
35 |
36 | gulp.task(taskName, [copyFilesOutdirTaskName]);
37 |
38 | return taskName;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/core/tasks/inline-html-css.task.ts:
--------------------------------------------------------------------------------
1 | import { OptionsKeys } from '../../model/options.keys';
2 | import { templateProcessor } from './inline-html-css.helpers/template.processor';
3 | import { styleProcessor } from './inline-html-css.helpers/style.processor';
4 | import * as plumber from 'gulp-plumber';
5 |
6 | const gulp = require('gulp');
7 | const inlineNg2Template = require('gulp-inline-ng2-template');
8 |
9 | /**
10 | * The task that inlines HTML and CSS inside the component
11 | * It replaces templateUrl with template
12 | * and also styleUrls with styles
13 | */
14 | export class InlineHtmlCssTask {
15 |
16 | /**
17 | * Registring the task
18 | */
19 | registerTask(argv: any, onError: () => void, dependencies: string[] = []): string {
20 | const taskName = 'inline-html-css-task';
21 | const inputFolder = `./${argv[OptionsKeys.ROOT_DIR]}`;
22 | const inputTypescriptFiles = `${inputFolder}/**/*.ts`;
23 | const rejectTypescriptSpecFiles = `!${inputFolder}/**/*.spec.ts`;
24 | const destFolder = `./${argv[OptionsKeys.OUT_DIR]}`;
25 |
26 | gulp.task(taskName, dependencies, () => {
27 | return gulp.src([inputTypescriptFiles, rejectTypescriptSpecFiles])
28 | .pipe(plumber(onError))
29 | .pipe(inlineNg2Template(this.getInlineNg2ConfigObject(inputFolder)))
30 | .pipe(gulp.dest(destFolder));
31 | });
32 |
33 | return taskName;
34 | }
35 |
36 | /**
37 | * Some default config settings for gulp-inline-ng2-template
38 | */
39 | private getInlineNg2ConfigObject(inputFolder: string) {
40 | return {
41 | base: inputFolder,
42 | useRelativePaths: true,
43 | removeLineBreaks: true,
44 | supportNonExistentFiles: true,
45 | templateProcessor: templateProcessor,
46 | styleProcessor: styleProcessor,
47 | };
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/core/tasks/copy-tsconfig-ngc.task.ts:
--------------------------------------------------------------------------------
1 | import { ITask } from './task.interface';
2 | import { OptionsKeys } from '../../model/options.keys';
3 | import * as path from 'path';
4 | import * as plumber from 'gulp-plumber';
5 |
6 | const gulp = require('gulp');
7 | const mergeJson = require('gulp-merge-json');
8 |
9 | /**
10 | * Copy tsconfig-ngc.json to the outDir folder
11 | */
12 | export class CopyTsconfigNgcTask implements ITask {
13 | /**
14 | * tsconfig-ngc.json path.
15 | * Path from this file to tsconfig-ngc.json when project is compiled to javascript
16 | */
17 | static tsconfigName = 'tsconfig-ngc.json';
18 | static tsconfigPath = `../../${CopyTsconfigNgcTask.tsconfigName}`;
19 |
20 | /**
21 | * Registring the task
22 | */
23 | registerTask(argv: any, onError: () => void, dependencies: string[] = []): string {
24 | const taskName = 'copy-tsconfig-ngc-task';
25 | const pathDefaultTsconfig = this.getPathToDefaultTsconfig();
26 | const pathCustomTsconfig = argv[OptionsKeys.TSCONFIG] || pathDefaultTsconfig;
27 |
28 | gulp.task(taskName, dependencies, () => {
29 | return gulp.src([pathDefaultTsconfig, pathCustomTsconfig])
30 | .pipe(plumber(onError))
31 | .pipe(mergeJson({
32 | fileName: CopyTsconfigNgcTask.tsconfigName,
33 | concatArrays: false,
34 | mergeArrays: false
35 | }))
36 | .pipe(gulp.dest(argv[OptionsKeys.OUT_DIR]));
37 | });
38 |
39 | return taskName;
40 | }
41 |
42 | /**
43 | * Get path to default tsconfig from current working directory (cwd)
44 | */
45 | getPathToDefaultTsconfig() {
46 | const pathFromDirname = path.resolve(__dirname, CopyTsconfigNgcTask.tsconfigPath);
47 | const relativePathFromCwd = path.relative(process.cwd(), pathFromDirname);
48 | return relativePathFromCwd;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-library-builder",
3 | "keywords": [],
4 | "author": "",
5 | "license": "MIT",
6 | "version": "0.0.0-semantically-released",
7 | "description": "CLI Tool to build Angular (2+) libraries ready to be published to npm",
8 | "bin": {
9 | "nglb": "./bin/nglb.js",
10 | "angular-library-builder": "./bin/nglb.js"
11 | },
12 | "scripts": {
13 | "test": "nyc mocha src/**/*.spec.ts --timeout 15000",
14 | "report-coverage": "codecov",
15 | "example": "npm run build && node bin/nglb.js --rootDir test/fixtures/basic-html-no-css/input --outDir test/fixtures/basic-html-no-css/output",
16 | "lint": "tslint --project tsconfig.json --type-check src/**/*.ts",
17 | "build": "tsc -p tsconfig.json",
18 | "prepublish": "npm run build",
19 | "commit": "git-cz",
20 | "semantic-release": "semantic-release pre && npm publish && semantic-release post"
21 | },
22 | "dependencies": {
23 | "@angular/compiler": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
24 | "@angular/compiler-cli": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
25 | "@angular/core": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
26 | "autoprefixer": "~7.1.3",
27 | "chalk": "^2.1.0",
28 | "csso": "~3.2.0",
29 | "del": "~3.0.0",
30 | "gulp": "~3.9.1",
31 | "gulp-inline-ng2-template": "~4.0.0",
32 | "gulp-merge-json": "^1.1.0",
33 | "gulp-plumber": "^1.1.0",
34 | "html-minifier": "~3.5.3",
35 | "node-sass": "~4.5.3",
36 | "postcss": "~6.0.10",
37 | "rxjs": "^5.4.3",
38 | "typescript": "2.5.3",
39 | "yargs": "~9.0.1",
40 | "zone.js": "^0.8.17"
41 | },
42 | "devDependencies": {
43 | "@types/chai": "~4.0.4",
44 | "@types/chalk": "~0.4.31",
45 | "@types/del": "~3.0.0",
46 | "@types/gulp-plumber": "~0.0.31",
47 | "@types/html-minifier": "~1.1.30",
48 | "@types/mocha": "~2.2.42",
49 | "@types/node": "~8.0.26",
50 | "@types/node-sass": "~3.10.32",
51 | "@types/yargs": "~8.0.2",
52 | "chai": "~4.1.2",
53 | "chai-fs": "~1.0.0",
54 | "codecov": "~2.3.0",
55 | "commitizen": "~2.9.6",
56 | "cz-conventional-changelog": "~2.1.0",
57 | "mocha": "~4.0.0",
58 | "nyc": "~11.3.0",
59 | "semantic-release": "~8.2.0",
60 | "ts-node": "~3.3.0",
61 | "tslint": "~5.7.0",
62 | "tslint-config-standard": "~6.0.1"
63 | },
64 | "engines": {
65 | "node": ">=6"
66 | },
67 | "repository": {
68 | "type": "git",
69 | "url": "https://github.com/bmvantunes/angular-library-builder.git"
70 | },
71 | "bugs": {
72 | "url": "https://github.com/bmvantunes/angular-library-builder/issues"
73 | },
74 | "homepage": "https://github.com/bmvantunes/angular-library-builder#readme",
75 | "config": {
76 | "commitizen": {
77 | "path": "./node_modules/cz-conventional-changelog"
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-library-builder",
3 | "keywords": [],
4 | "author": "",
5 | "license": "MIT",
6 | "version": "0.0.0-semantically-released",
7 | "description": "CLI Tool to build Angular (2+) libraries ready to be published to npm",
8 | "bin": {
9 | "nglb": "./bin/nglb.js",
10 | "angular-library-builder": "./bin/nglb.js"
11 | },
12 | "scripts": {
13 | "test": "nyc mocha src/**/*.spec.ts --timeout 15000",
14 | "report-coverage": "codecov",
15 | "example": "npm run build && node bin/nglb.js --rootDir test/fixtures/basic-html-no-css/input --outDir test/fixtures/basic-html-no-css/output",
16 | "lint": "tslint --project tsconfig.json --type-check src/**/*.ts",
17 | "build": "tsc -p tsconfig.json",
18 | "prepublish": "npm run build",
19 | "commit": "git-cz",
20 | "semantic-release": "semantic-release pre && npm publish && semantic-release post"
21 | },
22 | "dependencies": {
23 | "@angular/compiler": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
24 | "@angular/compiler-cli": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
25 | "@angular/core": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
26 | "autoprefixer": "~6.7.6",
27 | "chalk": "^1.1.3",
28 | "csso": "~3.0.0",
29 | "del": "~2.2.2",
30 | "gulp": "~3.9.1",
31 | "gulp-inline-ng2-template": "~4.0.0",
32 | "gulp-merge-json": "^1.0.0",
33 | "gulp-plumber": "^1.1.0",
34 | "html-minifier": "~3.4.0",
35 | "node-sass": "~4.5.0",
36 | "postcss": "~5.2.15",
37 | "rxjs": "^5.1.0",
38 | "typescript": "~2.2.0",
39 | "yargs": "~7.0.1",
40 | "zone.js": "^0.8.5"
41 | },
42 | "devDependencies": {
43 | "@types/chai": "~3.5.0",
44 | "@types/chalk": "^0.4.31",
45 | "@types/del": "~2.2.32",
46 | "@types/gulp": "~4.0.0",
47 | "@types/gulp-plumber": "0.0.30",
48 | "@types/html-minifier": "~1.1.30",
49 | "@types/mocha": "~2.2.39",
50 | "@types/node": "~7.0.5",
51 | "@types/node-sass": "~3.10.32",
52 | "@types/yargs": "~6.6.0",
53 | "chai": "~3.5.0",
54 | "chai-fs": "~1.0.0",
55 | "codecov": "^2.0.1",
56 | "commitizen": "~2.9.6",
57 | "cz-conventional-changelog": "~2.0.0",
58 | "mocha": "~3.2.0",
59 | "nyc": "~10.2.0",
60 | "semantic-release": "~6.3.2",
61 | "ts-node": "~3.0.0",
62 | "tslint": "~5.1.0",
63 | "tslint-config-standard": "~5.0.1"
64 | },
65 | "engines": {
66 | "node": ">=6"
67 | },
68 | "repository": {
69 | "type": "git",
70 | "url": "https://github.com/bmvantunes/angular-library-builder.git"
71 | },
72 | "bugs": {
73 | "url": "https://github.com/bmvantunes/angular-library-builder/issues"
74 | },
75 | "homepage": "https://github.com/bmvantunes/angular-library-builder#readme",
76 | "config": {
77 | "commitizen": {
78 | "path": "./node_modules/cz-conventional-changelog"
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-library-builder",
3 | "keywords": [],
4 | "author": "",
5 | "license": "MIT",
6 | "version": "0.0.0-semantically-released",
7 | "description": "CLI Tool to build Angular (2+) libraries ready to be published to npm",
8 | "bin": {
9 | "nglb": "./bin/nglb.js",
10 | "angular-library-builder": "./bin/nglb.js"
11 | },
12 | "scripts": {
13 | "test": "nyc mocha src/**/*.spec.ts --timeout 15000",
14 | "report-coverage": "codecov",
15 | "example": "npm run build && node bin/nglb.js --rootDir test/fixtures/basic-html-no-css/input --outDir test/fixtures/basic-html-no-css/output",
16 | "lint": "tslint --project tsconfig.json --type-check src/**/*.ts",
17 | "build": "tsc -p tsconfig.json",
18 | "prepublish": "npm run build",
19 | "commit": "git-cz",
20 | "semantic-release": "semantic-release pre && npm publish && semantic-release post"
21 | },
22 | "dependencies": {
23 | "@angular/compiler": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
24 | "@angular/compiler-cli": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
25 | "@angular/core": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
26 | "autoprefixer": "~6.7.6",
27 | "chalk": "^1.1.3",
28 | "csso": "~3.0.0",
29 | "del": "~2.2.2",
30 | "gulp": "~3.9.1",
31 | "gulp-inline-ng2-template": "~4.0.0",
32 | "gulp-merge-json": "^1.0.0",
33 | "gulp-plumber": "^1.1.0",
34 | "html-minifier": "~3.4.0",
35 | "node-sass": "~4.5.0",
36 | "postcss": "~5.2.15",
37 | "rxjs": "^5.1.0",
38 | "typescript": "~2.2.0",
39 | "yargs": "~7.0.1",
40 | "zone.js": "^0.8.5"
41 | },
42 | "devDependencies": {
43 | "@types/chai": "~3.5.0",
44 | "@types/chalk": "^0.4.31",
45 | "@types/del": "~2.2.32",
46 | "@types/gulp": "~4.0.0",
47 | "@types/gulp-plumber": "0.0.30",
48 | "@types/html-minifier": "~1.1.30",
49 | "@types/mocha": "~2.2.39",
50 | "@types/node": "~7.0.5",
51 | "@types/node-sass": "~3.10.32",
52 | "@types/yargs": "~6.6.0",
53 | "chai": "~3.5.0",
54 | "chai-fs": "~1.0.0",
55 | "codecov": "^2.0.1",
56 | "commitizen": "~2.9.6",
57 | "cz-conventional-changelog": "~2.0.0",
58 | "mocha": "~3.2.0",
59 | "nyc": "~10.2.0",
60 | "semantic-release": "~6.3.2",
61 | "ts-node": "~3.0.0",
62 | "tslint": "~5.1.0",
63 | "tslint-config-standard": "~5.0.1"
64 | },
65 | "engines": {
66 | "node": ">=6"
67 | },
68 | "repository": {
69 | "type": "git",
70 | "url": "https://github.com/bmvantunes/angular-library-builder.git"
71 | },
72 | "bugs": {
73 | "url": "https://github.com/bmvantunes/angular-library-builder/issues"
74 | },
75 | "homepage": "https://github.com/bmvantunes/angular-library-builder#readme",
76 | "config": {
77 | "commitizen": {
78 | "path": "./node_modules/cz-conventional-changelog"
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-library-builder",
3 | "keywords": [],
4 | "author": "",
5 | "license": "MIT",
6 | "version": "0.0.0-semantically-released",
7 | "description": "CLI Tool to build Angular (2+) libraries ready to be published to npm",
8 | "bin": {
9 | "nglb": "./bin/nglb.js",
10 | "angular-library-builder": "./bin/nglb.js"
11 | },
12 | "scripts": {
13 | "test": "nyc mocha src/**/*.spec.ts --timeout 15000",
14 | "report-coverage": "codecov",
15 | "example": "npm run build && node bin/nglb.js --rootDir test/fixtures/basic-html-no-css/input --outDir test/fixtures/basic-html-no-css/output",
16 | "lint": "tslint --project tsconfig.json --type-check src/**/*.ts",
17 | "build": "tsc -p tsconfig.json",
18 | "prepublish": "npm run build",
19 | "commit": "git-cz",
20 | "semantic-release": "semantic-release pre && npm publish && semantic-release post"
21 | },
22 | "dependencies": {
23 | "@angular/compiler": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
24 | "@angular/compiler-cli": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
25 | "@angular/core": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
26 | "autoprefixer": "~6.7.6",
27 | "chalk": "^1.1.3",
28 | "csso": "~3.0.0",
29 | "del": "~2.2.2",
30 | "gulp": "~3.9.1",
31 | "gulp-inline-ng2-template": "~4.0.0",
32 | "gulp-merge-json": "^1.0.0",
33 | "gulp-plumber": "^1.1.0",
34 | "html-minifier": "~3.4.0",
35 | "node-sass": "~4.5.0",
36 | "postcss": "~5.2.15",
37 | "rxjs": "^5.1.0",
38 | "typescript": "~2.2.0",
39 | "yargs": "~7.0.1",
40 | "zone.js": "^0.8.5"
41 | },
42 | "devDependencies": {
43 | "@types/chai": "~3.5.0",
44 | "@types/chalk": "^0.4.31",
45 | "@types/del": "~2.2.32",
46 | "@types/gulp": "~4.0.0",
47 | "@types/gulp-plumber": "0.0.30",
48 | "@types/html-minifier": "~1.1.30",
49 | "@types/mocha": "~2.2.39",
50 | "@types/node": "~7.0.5",
51 | "@types/node-sass": "~3.10.32",
52 | "@types/yargs": "~6.6.0",
53 | "chai": "~3.5.0",
54 | "chai-fs": "~1.0.0",
55 | "codecov": "^2.0.1",
56 | "commitizen": "~2.9.6",
57 | "cz-conventional-changelog": "~2.0.0",
58 | "mocha": "~3.2.0",
59 | "nyc": "~10.2.0",
60 | "semantic-release": "~6.3.2",
61 | "ts-node": "~3.0.0",
62 | "tslint": "~5.1.0",
63 | "tslint-config-standard": "~5.0.1"
64 | },
65 | "engines": {
66 | "node": ">=6"
67 | },
68 | "repository": {
69 | "type": "git",
70 | "url": "https://github.com/bmvantunes/angular-library-builder.git"
71 | },
72 | "bugs": {
73 | "url": "https://github.com/bmvantunes/angular-library-builder/issues"
74 | },
75 | "homepage": "https://github.com/bmvantunes/angular-library-builder#readme",
76 | "config": {
77 | "commitizen": {
78 | "path": "./node_modules/cz-conventional-changelog"
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-library-builder",
3 | "keywords": [],
4 | "author": "",
5 | "license": "MIT",
6 | "version": "0.0.0-semantically-released",
7 | "description": "CLI Tool to build Angular (2+) libraries ready to be published to npm",
8 | "bin": {
9 | "nglb": "./bin/nglb.js",
10 | "angular-library-builder": "./bin/nglb.js"
11 | },
12 | "scripts": {
13 | "test": "nyc mocha src/**/*.spec.ts --timeout 15000",
14 | "report-coverage": "codecov",
15 | "example": "npm run build && node bin/nglb.js --rootDir test/fixtures/basic-html-no-css/input --outDir test/fixtures/basic-html-no-css/output",
16 | "lint": "tslint --project tsconfig.json --type-check src/**/*.ts",
17 | "build": "tsc -p tsconfig.json",
18 | "prepublish": "npm run build",
19 | "commit": "git-cz",
20 | "semantic-release": "semantic-release pre && npm publish && semantic-release post"
21 | },
22 | "dependencies": {
23 | "@angular/compiler": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
24 | "@angular/compiler-cli": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
25 | "@angular/core": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
26 | "autoprefixer": "~6.7.6",
27 | "chalk": "^1.1.3",
28 | "csso": "~3.0.0",
29 | "del": "~2.2.2",
30 | "gulp": "~3.9.1",
31 | "gulp-inline-ng2-template": "~4.0.0",
32 | "gulp-merge-json": "^1.0.0",
33 | "gulp-plumber": "^1.1.0",
34 | "html-minifier": "~3.4.0",
35 | "node-sass": "~4.5.0",
36 | "postcss": "~5.2.15",
37 | "rxjs": "^5.1.0",
38 | "typescript": "~2.2.0",
39 | "yargs": "~7.0.1",
40 | "zone.js": "^0.8.5"
41 | },
42 | "devDependencies": {
43 | "@types/chai": "~3.5.0",
44 | "@types/chalk": "^0.4.31",
45 | "@types/del": "~2.2.32",
46 | "@types/gulp": "~4.0.0",
47 | "@types/gulp-plumber": "0.0.30",
48 | "@types/html-minifier": "~1.1.30",
49 | "@types/mocha": "~2.2.39",
50 | "@types/node": "~7.0.5",
51 | "@types/node-sass": "~3.10.32",
52 | "@types/yargs": "~6.6.0",
53 | "chai": "~3.5.0",
54 | "chai-fs": "~1.0.0",
55 | "codecov": "^2.0.1",
56 | "commitizen": "~2.9.6",
57 | "cz-conventional-changelog": "~2.0.0",
58 | "mocha": "~3.2.0",
59 | "nyc": "~10.2.0",
60 | "semantic-release": "~6.3.2",
61 | "ts-node": "~3.0.0",
62 | "tslint": "~5.1.0",
63 | "tslint-config-standard": "~5.0.1"
64 | },
65 | "engines": {
66 | "node": ">=6"
67 | },
68 | "repository": {
69 | "type": "git",
70 | "url": "https://github.com/bmvantunes/angular-library-builder.git"
71 | },
72 | "bugs": {
73 | "url": "https://github.com/bmvantunes/angular-library-builder/issues"
74 | },
75 | "homepage": "https://github.com/bmvantunes/angular-library-builder#readme",
76 | "config": {
77 | "commitizen": {
78 | "path": "./node_modules/cz-conventional-changelog"
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-library-builder",
3 | "keywords": [],
4 | "author": "",
5 | "license": "MIT",
6 | "version": "0.0.0-semantically-released",
7 | "description": "CLI Tool to build Angular (2+) libraries ready to be published to npm",
8 | "bin": {
9 | "nglb": "./bin/nglb.js",
10 | "angular-library-builder": "./bin/nglb.js"
11 | },
12 | "scripts": {
13 | "test": "nyc mocha src/**/*.spec.ts --timeout 15000",
14 | "report-coverage": "codecov",
15 | "example": "npm run build && node bin/nglb.js --rootDir test/fixtures/basic-html-no-css/input --outDir test/fixtures/basic-html-no-css/output",
16 | "lint": "tslint --project tsconfig.json --type-check src/**/*.ts",
17 | "build": "tsc -p tsconfig.json",
18 | "prepublish": "npm run build",
19 | "commit": "git-cz",
20 | "semantic-release": "semantic-release pre && npm publish && semantic-release post"
21 | },
22 | "dependencies": {
23 | "@angular/compiler": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
24 | "@angular/compiler-cli": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
25 | "@angular/core": ">=2.3.1 <5.0.0 || >=4.0.0-beta <5.0.0",
26 | "autoprefixer": "~6.7.6",
27 | "chalk": "^1.1.3",
28 | "csso": "~3.0.0",
29 | "del": "~2.2.2",
30 | "gulp": "~3.9.1",
31 | "gulp-inline-ng2-template": "~4.0.0",
32 | "gulp-merge-json": "^1.0.0",
33 | "gulp-plumber": "^1.1.0",
34 | "html-minifier": "~3.4.0",
35 | "node-sass": "~4.5.0",
36 | "postcss": "~5.2.15",
37 | "rxjs": "^5.1.0",
38 | "typescript": "~2.2.0",
39 | "yargs": "~7.0.1",
40 | "zone.js": "^0.8.5"
41 | },
42 | "devDependencies": {
43 | "@types/chai": "~3.5.0",
44 | "@types/chalk": "^0.4.31",
45 | "@types/del": "~2.2.32",
46 | "@types/gulp": "~4.0.0",
47 | "@types/gulp-plumber": "0.0.30",
48 | "@types/html-minifier": "~1.1.30",
49 | "@types/mocha": "~2.2.39",
50 | "@types/node": "~7.0.5",
51 | "@types/node-sass": "~3.10.32",
52 | "@types/yargs": "~6.6.0",
53 | "chai": "~3.5.0",
54 | "chai-fs": "~1.0.0",
55 | "codecov": "^2.0.1",
56 | "commitizen": "~2.9.6",
57 | "cz-conventional-changelog": "~2.0.0",
58 | "mocha": "~3.2.0",
59 | "nyc": "~10.2.0",
60 | "semantic-release": "~6.3.2",
61 | "ts-node": "~3.0.0",
62 | "tslint": "~5.1.0",
63 | "tslint-config-standard": "~5.0.1"
64 | },
65 | "engines": {
66 | "node": ">=6"
67 | },
68 | "repository": {
69 | "type": "git",
70 | "url": "https://github.com/bmvantunes/angular-library-builder.git"
71 | },
72 | "bugs": {
73 | "url": "https://github.com/bmvantunes/angular-library-builder/issues"
74 | },
75 | "homepage": "https://github.com/bmvantunes/angular-library-builder#readme",
76 | "config": {
77 | "commitizen": {
78 | "path": "./node_modules/cz-conventional-changelog"
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/core/angular-library-builder.spec.ts:
--------------------------------------------------------------------------------
1 | import { expect } from 'chai';
2 | import * as chai from 'chai';
3 |
4 | import { AngularLibraryBuilder } from './angular-library-builder';
5 | import { OptionsKeys } from '../model/options.keys';
6 | import { CopyTsconfigNgcTask } from './tasks/copy-tsconfig-ngc.task';
7 |
8 | describe('Integration Tests', () => {
9 | // We need this in order to run with ts-node inside src folder instead of project root
10 | CopyTsconfigNgcTask.tsconfigPath = `../${CopyTsconfigNgcTask.tsconfigPath}`;
11 |
12 | beforeEach(() => {
13 | chai.use(require('chai-fs'));
14 | });
15 |
16 | it('should be able to handle Basic html, basic css and scss files', (done) => {
17 | runIntegrationTestExpectSuccess('basic-html-basic-scss-and-css', false, done);
18 | });
19 |
20 | it('should process html with Angular attributes [property] and *ngIf', (done) => {
21 | runIntegrationTestExpectSuccess('basic-html-no-css', false, done);
22 | });
23 |
24 | it('should allow empty/no-content scss files without node-sass errors', (done) => {
25 | runIntegrationTestExpectSuccess('allow-empty-scss-files', false, done);
26 | });
27 |
28 | it('should ignore all *.spec.ts files and not output them to outDir folder', (done) => {
29 | runIntegrationTestExpectSuccess('basic-html-no-css-with-spec-files', false, done);
30 | });
31 |
32 | it('should override the tsconfig basic-html-no-css-override-tsconfig', (done) => {
33 | runIntegrationTestExpectSuccess('basic-html-no-css-override-tsconfig', true, done);
34 | });
35 |
36 | // it('Expect Scss problems - Exception', (done) => {
37 | // runIntegrationTestExpectExceptionNoOutput('scss-does-not-compile', done);
38 | // });
39 | });
40 |
41 | // function runIntegrationTestExpectExceptionNoOutput(testName: string, done: Function) {
42 | // const inputFolder = `test/fixtures/${testName}/input`;
43 | // const outputFolder = `test/fixtures/${testName}/output`;
44 | // // const expectedOutputFolder = `test/fixtures/${testName}/output-expected`;
45 |
46 | // const builder = new AngularLibraryBuilder({
47 | // [OptionsKeys.ROOT_DIR]: inputFolder,
48 | // [OptionsKeys.OUT_DIR]: outputFolder,
49 | // });
50 |
51 | // expect(builder.buildLibrary).to.throw();
52 | // }
53 |
54 | function runIntegrationTestExpectSuccess(testName: string, overrideTsconfig: boolean, done: Function) {
55 | const inputFolder = `test/fixtures/${testName}/input`;
56 | const outputFolder = `test/fixtures/${testName}/output`;
57 | const expectedOutputFolder = `test/fixtures/${testName}/output-expected`;
58 | const tsconfigOverrideLocation = `test/fixtures/${testName}/input/override-tsconfig.json`;
59 |
60 | const parameters = {
61 | [OptionsKeys.ROOT_DIR]: inputFolder,
62 | [OptionsKeys.OUT_DIR]: outputFolder,
63 | [OptionsKeys.TSCONFIG]: tsconfigOverrideLocation
64 | };
65 |
66 | if (!overrideTsconfig) {
67 | delete parameters[OptionsKeys.TSCONFIG];
68 | }
69 |
70 | const builder = new AngularLibraryBuilder(parameters);
71 |
72 | builder.onSuccess = () => {
73 | (expect(outputFolder).to.be.a as any).directory().and.equal(expectedOutputFolder);
74 | done();
75 | };
76 |
77 | builder.buildLibrary();
78 | }
79 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css/output-expected/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/bmvantunes/angular-library-builder)
2 | [](https://david-dm.org/bmvantunes/angular-library-builder)
3 | [](https://david-dm.org/bmvantunes/angular-library-builder?type=dev)
4 | [](https://github.com/semantic-release/semantic-release)
5 | [](https://badge.fury.io/js/angular-library-builder)
6 | [](https://codecov.io/gh/bmvantunes/angular-library-builder)
7 | [](http://commitizen.github.io/cz-cli/)
8 | [](https://greenkeeper.io/)
9 |
10 | # What is Angular Library Builder (nglb)?
11 |
12 | It's a CLI Tool to build Angular (2+) libraries ready to be published to [npm](https://www.npmjs.com/).
13 |
14 | ### What problem is Angular Library Builder (nglb) trying to solve?
15 |
16 | At the moment there is no official documentation/guidelines on how to build and publish Angular (2+) components/libraries/services/modules to npm. Angular Library Builder (nglb) is trying to solve this in the easiest way possible.
17 |
18 | ### How does Angular Library Builder (nglb) solve this?
19 |
20 | 1. If it is a component, inlines html template file into the component as a string, replacing `templateUrl` with `template`
21 | - In the inlining process nglb also minifies html using [html-minifier](https://www.npmjs.com/package/html-minifier)
22 | 2. If it is a component, inlines scss/sass/css file(s) into the component as a string, replacing `stylesUrls` with `styles`. It uses:
23 | - [node-sass](https://www.npmjs.com/package/node-sass) to compile scss/sass file(s)
24 | - [autoprefixer](https://www.npmjs.com/package/autoprefixer) to improve browser compatibilty
25 | - [csso](https://www.npmjs.com/package/csso) to minimize/optimize your css
26 | 3. Finally, it compiles your resulting typescript files with all your html and css inlined, using @angular/compiler-cli (ngc), creating `*.d.ts`, `*.js`, `*.js.map`, `*.metadata.json` files
27 |
28 | # Getting Started
29 |
30 | #### Install the `angular-library-builder` command
31 |
32 | ```sh
33 | npm install --save-dev angular-library-builder
34 | ```
35 |
36 | #### How to use `angular-library-builder`?
37 |
38 | Add angular-library-builder (nglb) script, main and types to `package.json`:
39 |
40 | ```json
41 | "main": "./lib-dist/your-main-file.js",
42 | "types": "./lib-dist/your-main-file.d.ts",
43 | "scripts": {
44 | "build:library": "nglb --rootDir src/lib --outDir lib-dist"
45 | }
46 | ```
47 | or
48 | ```json
49 | "main": "./lib-dist/your-main-file.js",
50 | "types": "./lib-dist/your-main-file.d.ts",
51 | "scripts": {
52 | "build:library": "angular-library-builder --rootDir src/lib --outDir lib-dist"
53 | }
54 | ```
55 |
56 | Now, in your project root:
57 | ```sh
58 | npm run build:library
59 | ```
60 |
61 | Congratulations! Your library is available in lib-dist folder ready to be published to npm.
62 |
63 | To publish your new library to npm, execute the following command in your project root:
64 | ```sh
65 | npm publish
66 | ```
67 |
68 | #### Options that `angular-library-builder` supports
69 | option (argument) | description
70 | ------------ | -------------
71 | --rootDir | Specifies the root directory of input files. Example: ```nglb --rootDir src```, [required]
72 | --outDir | Redirect output structure to the directory. Example: ```nglb --outDir dist```, [required]
73 | --tsconfig | Possibility to extend/override properties in default [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json). Example: ```nglb --tsconfig path/to/your/override-tsconfig-ngc.json```
74 | --help (-h) | Print help message
75 |
76 |
77 | # How to change `angular-library-builder` [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json) default properties?
78 | Sometimes the defaults aren't good enough for everybody.
79 |
80 | #### Example
81 | Let's imagine that you want to change slightly the build process:
82 | 1. change the default "target" from "es5" to "es2015"
83 | 2. add a new property, for example, "noImplicitAny": true,
84 |
85 | To acomplish this create a file called, for example, ```override-tsconfig-ngc.json``` in your project root.
86 | Your ```override-tsconfig-ngc.json``` file can be something like:
87 | ```json
88 | {
89 | "compilerOptions": {
90 | "target": "es2015",
91 | "noImplicitAny": true
92 | }
93 | }
94 | ```
95 |
96 | Then, you invoke nglb like this:
97 | ```bash
98 | nglb --rootDir path/to/your/source --outDir path/to/dist --tsconfig override-tsconfig-ngc.json
99 | ```
100 |
101 | # Authors and Contributors
102 |
103 | @bmvantunes (Bruno Antunes, author)
104 |
105 | Special thanks to [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template). Without [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template) `angular-library-builder` would not be possible!
106 |
107 | # License
108 |
109 | The repository code is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
110 |
--------------------------------------------------------------------------------
/test/fixtures/allow-empty-scss-files/output-expected/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/bmvantunes/angular-library-builder)
2 | [](https://david-dm.org/bmvantunes/angular-library-builder)
3 | [](https://david-dm.org/bmvantunes/angular-library-builder?type=dev)
4 | [](https://github.com/semantic-release/semantic-release)
5 | [](https://badge.fury.io/js/angular-library-builder)
6 | [](https://codecov.io/gh/bmvantunes/angular-library-builder)
7 | [](http://commitizen.github.io/cz-cli/)
8 | [](https://greenkeeper.io/)
9 |
10 | # What is Angular Library Builder (nglb)?
11 |
12 | It's a CLI Tool to build Angular (2+) libraries ready to be published to [npm](https://www.npmjs.com/).
13 |
14 | ### What problem is Angular Library Builder (nglb) trying to solve?
15 |
16 | At the moment there is no official documentation/guidelines on how to build and publish Angular (2+) components/libraries/services/modules to npm. Angular Library Builder (nglb) is trying to solve this in the easiest way possible.
17 |
18 | ### How does Angular Library Builder (nglb) solve this?
19 |
20 | 1. If it is a component, inlines html template file into the component as a string, replacing `templateUrl` with `template`
21 | - In the inlining process nglb also minifies html using [html-minifier](https://www.npmjs.com/package/html-minifier)
22 | 2. If it is a component, inlines scss/sass/css file(s) into the component as a string, replacing `stylesUrls` with `styles`. It uses:
23 | - [node-sass](https://www.npmjs.com/package/node-sass) to compile scss/sass file(s)
24 | - [autoprefixer](https://www.npmjs.com/package/autoprefixer) to improve browser compatibilty
25 | - [csso](https://www.npmjs.com/package/csso) to minimize/optimize your css
26 | 3. Finally, it compiles your resulting typescript files with all your html and css inlined, using @angular/compiler-cli (ngc), creating `*.d.ts`, `*.js`, `*.js.map`, `*.metadata.json` files
27 |
28 | # Getting Started
29 |
30 | #### Install the `angular-library-builder` command
31 |
32 | ```sh
33 | npm install --save-dev angular-library-builder
34 | ```
35 |
36 | #### How to use `angular-library-builder`?
37 |
38 | Add angular-library-builder (nglb) script, main and types to `package.json`:
39 |
40 | ```json
41 | "main": "./lib-dist/your-main-file.js",
42 | "types": "./lib-dist/your-main-file.d.ts",
43 | "scripts": {
44 | "build:library": "nglb --rootDir src/lib --outDir lib-dist"
45 | }
46 | ```
47 | or
48 | ```json
49 | "main": "./lib-dist/your-main-file.js",
50 | "types": "./lib-dist/your-main-file.d.ts",
51 | "scripts": {
52 | "build:library": "angular-library-builder --rootDir src/lib --outDir lib-dist"
53 | }
54 | ```
55 |
56 | Now, in your project root:
57 | ```sh
58 | npm run build:library
59 | ```
60 |
61 | Congratulations! Your library is available in lib-dist folder ready to be published to npm.
62 |
63 | To publish your new library to npm, execute the following command in your project root:
64 | ```sh
65 | npm publish
66 | ```
67 |
68 | #### Options that `angular-library-builder` supports
69 | option (argument) | description
70 | ------------ | -------------
71 | --rootDir | Specifies the root directory of input files. Example: ```nglb --rootDir src```, [required]
72 | --outDir | Redirect output structure to the directory. Example: ```nglb --outDir dist```, [required]
73 | --tsconfig | Possibility to extend/override properties in default [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json). Example: ```nglb --tsconfig path/to/your/override-tsconfig-ngc.json```
74 | --help (-h) | Print help message
75 |
76 |
77 | # How to change `angular-library-builder` [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json) default properties?
78 | Sometimes the defaults aren't good enough for everybody.
79 |
80 | #### Example
81 | Let's imagine that you want to change slightly the build process:
82 | 1. change the default "target" from "es5" to "es2015"
83 | 2. add a new property, for example, "noImplicitAny": true,
84 |
85 | To acomplish this create a file called, for example, ```override-tsconfig-ngc.json``` in your project root.
86 | Your ```override-tsconfig-ngc.json``` file can be something like:
87 | ```json
88 | {
89 | "compilerOptions": {
90 | "target": "es2015",
91 | "noImplicitAny": true
92 | }
93 | }
94 | ```
95 |
96 | Then, you invoke nglb like this:
97 | ```bash
98 | nglb --rootDir path/to/your/source --outDir path/to/dist --tsconfig override-tsconfig-ngc.json
99 | ```
100 |
101 | # Authors and Contributors
102 |
103 | @bmvantunes (Bruno Antunes, author)
104 |
105 | Special thanks to [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template). Without [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template) `angular-library-builder` would not be possible!
106 |
107 | # License
108 |
109 | The repository code is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
110 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-basic-scss-and-css/output-expected/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/bmvantunes/angular-library-builder)
2 | [](https://david-dm.org/bmvantunes/angular-library-builder)
3 | [](https://david-dm.org/bmvantunes/angular-library-builder?type=dev)
4 | [](https://github.com/semantic-release/semantic-release)
5 | [](https://badge.fury.io/js/angular-library-builder)
6 | [](https://codecov.io/gh/bmvantunes/angular-library-builder)
7 | [](http://commitizen.github.io/cz-cli/)
8 | [](https://greenkeeper.io/)
9 |
10 | # What is Angular Library Builder (nglb)?
11 |
12 | It's a CLI Tool to build Angular (2+) libraries ready to be published to [npm](https://www.npmjs.com/).
13 |
14 | ### What problem is Angular Library Builder (nglb) trying to solve?
15 |
16 | At the moment there is no official documentation/guidelines on how to build and publish Angular (2+) components/libraries/services/modules to npm. Angular Library Builder (nglb) is trying to solve this in the easiest way possible.
17 |
18 | ### How does Angular Library Builder (nglb) solve this?
19 |
20 | 1. If it is a component, inlines html template file into the component as a string, replacing `templateUrl` with `template`
21 | - In the inlining process nglb also minifies html using [html-minifier](https://www.npmjs.com/package/html-minifier)
22 | 2. If it is a component, inlines scss/sass/css file(s) into the component as a string, replacing `stylesUrls` with `styles`. It uses:
23 | - [node-sass](https://www.npmjs.com/package/node-sass) to compile scss/sass file(s)
24 | - [autoprefixer](https://www.npmjs.com/package/autoprefixer) to improve browser compatibilty
25 | - [csso](https://www.npmjs.com/package/csso) to minimize/optimize your css
26 | 3. Finally, it compiles your resulting typescript files with all your html and css inlined, using @angular/compiler-cli (ngc), creating `*.d.ts`, `*.js`, `*.js.map`, `*.metadata.json` files
27 |
28 | # Getting Started
29 |
30 | #### Install the `angular-library-builder` command
31 |
32 | ```sh
33 | npm install --save-dev angular-library-builder
34 | ```
35 |
36 | #### How to use `angular-library-builder`?
37 |
38 | Add angular-library-builder (nglb) script, main and types to `package.json`:
39 |
40 | ```json
41 | "main": "./lib-dist/your-main-file.js",
42 | "types": "./lib-dist/your-main-file.d.ts",
43 | "scripts": {
44 | "build:library": "nglb --rootDir src/lib --outDir lib-dist"
45 | }
46 | ```
47 | or
48 | ```json
49 | "main": "./lib-dist/your-main-file.js",
50 | "types": "./lib-dist/your-main-file.d.ts",
51 | "scripts": {
52 | "build:library": "angular-library-builder --rootDir src/lib --outDir lib-dist"
53 | }
54 | ```
55 |
56 | Now, in your project root:
57 | ```sh
58 | npm run build:library
59 | ```
60 |
61 | Congratulations! Your library is available in lib-dist folder ready to be published to npm.
62 |
63 | To publish your new library to npm, execute the following command in your project root:
64 | ```sh
65 | npm publish
66 | ```
67 |
68 | #### Options that `angular-library-builder` supports
69 | option (argument) | description
70 | ------------ | -------------
71 | --rootDir | Specifies the root directory of input files. Example: ```nglb --rootDir src```, [required]
72 | --outDir | Redirect output structure to the directory. Example: ```nglb --outDir dist```, [required]
73 | --tsconfig | Possibility to extend/override properties in default [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json). Example: ```nglb --tsconfig path/to/your/override-tsconfig-ngc.json```
74 | --help (-h) | Print help message
75 |
76 |
77 | # How to change `angular-library-builder` [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json) default properties?
78 | Sometimes the defaults aren't good enough for everybody.
79 |
80 | #### Example
81 | Let's imagine that you want to change slightly the build process:
82 | 1. change the default "target" from "es5" to "es2015"
83 | 2. add a new property, for example, "noImplicitAny": true,
84 |
85 | To acomplish this create a file called, for example, ```override-tsconfig-ngc.json``` in your project root.
86 | Your ```override-tsconfig-ngc.json``` file can be something like:
87 | ```json
88 | {
89 | "compilerOptions": {
90 | "target": "es2015",
91 | "noImplicitAny": true
92 | }
93 | }
94 | ```
95 |
96 | Then, you invoke nglb like this:
97 | ```bash
98 | nglb --rootDir path/to/your/source --outDir path/to/dist --tsconfig override-tsconfig-ngc.json
99 | ```
100 |
101 | # Authors and Contributors
102 |
103 | @bmvantunes (Bruno Antunes, author)
104 |
105 | Special thanks to [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template). Without [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template) `angular-library-builder` would not be possible!
106 |
107 | # License
108 |
109 | The repository code is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
110 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-override-tsconfig/output-expected/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/bmvantunes/angular-library-builder)
2 | [](https://david-dm.org/bmvantunes/angular-library-builder)
3 | [](https://david-dm.org/bmvantunes/angular-library-builder?type=dev)
4 | [](https://github.com/semantic-release/semantic-release)
5 | [](https://badge.fury.io/js/angular-library-builder)
6 | [](https://codecov.io/gh/bmvantunes/angular-library-builder)
7 | [](http://commitizen.github.io/cz-cli/)
8 | [](https://greenkeeper.io/)
9 |
10 | # What is Angular Library Builder (nglb)?
11 |
12 | It's a CLI Tool to build Angular (2+) libraries ready to be published to [npm](https://www.npmjs.com/).
13 |
14 | ### What problem is Angular Library Builder (nglb) trying to solve?
15 |
16 | At the moment there is no official documentation/guidelines on how to build and publish Angular (2+) components/libraries/services/modules to npm. Angular Library Builder (nglb) is trying to solve this in the easiest way possible.
17 |
18 | ### How does Angular Library Builder (nglb) solve this?
19 |
20 | 1. If it is a component, inlines html template file into the component as a string, replacing `templateUrl` with `template`
21 | - In the inlining process nglb also minifies html using [html-minifier](https://www.npmjs.com/package/html-minifier)
22 | 2. If it is a component, inlines scss/sass/css file(s) into the component as a string, replacing `stylesUrls` with `styles`. It uses:
23 | - [node-sass](https://www.npmjs.com/package/node-sass) to compile scss/sass file(s)
24 | - [autoprefixer](https://www.npmjs.com/package/autoprefixer) to improve browser compatibilty
25 | - [csso](https://www.npmjs.com/package/csso) to minimize/optimize your css
26 | 3. Finally, it compiles your resulting typescript files with all your html and css inlined, using @angular/compiler-cli (ngc), creating `*.d.ts`, `*.js`, `*.js.map`, `*.metadata.json` files
27 |
28 | # Getting Started
29 |
30 | #### Install the `angular-library-builder` command
31 |
32 | ```sh
33 | npm install --save-dev angular-library-builder
34 | ```
35 |
36 | #### How to use `angular-library-builder`?
37 |
38 | Add angular-library-builder (nglb) script, main and types to `package.json`:
39 |
40 | ```json
41 | "main": "./lib-dist/your-main-file.js",
42 | "types": "./lib-dist/your-main-file.d.ts",
43 | "scripts": {
44 | "build:library": "nglb --rootDir src/lib --outDir lib-dist"
45 | }
46 | ```
47 | or
48 | ```json
49 | "main": "./lib-dist/your-main-file.js",
50 | "types": "./lib-dist/your-main-file.d.ts",
51 | "scripts": {
52 | "build:library": "angular-library-builder --rootDir src/lib --outDir lib-dist"
53 | }
54 | ```
55 |
56 | Now, in your project root:
57 | ```sh
58 | npm run build:library
59 | ```
60 |
61 | Congratulations! Your library is available in lib-dist folder ready to be published to npm.
62 |
63 | To publish your new library to npm, execute the following command in your project root:
64 | ```sh
65 | npm publish
66 | ```
67 |
68 | #### Options that `angular-library-builder` supports
69 | option (argument) | description
70 | ------------ | -------------
71 | --rootDir | Specifies the root directory of input files. Example: ```nglb --rootDir src```, [required]
72 | --outDir | Redirect output structure to the directory. Example: ```nglb --outDir dist```, [required]
73 | --tsconfig | Possibility to extend/override properties in default [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json). Example: ```nglb --tsconfig path/to/your/override-tsconfig-ngc.json```
74 | --help (-h) | Print help message
75 |
76 |
77 | # How to change `angular-library-builder` [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json) default properties?
78 | Sometimes the defaults aren't good enough for everybody.
79 |
80 | #### Example
81 | Let's imagine that you want to change slightly the build process:
82 | 1. change the default "target" from "es5" to "es2015"
83 | 2. add a new property, for example, "noImplicitAny": true,
84 |
85 | To acomplish this create a file called, for example, ```override-tsconfig-ngc.json``` in your project root.
86 | Your ```override-tsconfig-ngc.json``` file can be something like:
87 | ```json
88 | {
89 | "compilerOptions": {
90 | "target": "es2015",
91 | "noImplicitAny": true
92 | }
93 | }
94 | ```
95 |
96 | Then, you invoke nglb like this:
97 | ```bash
98 | nglb --rootDir path/to/your/source --outDir path/to/dist --tsconfig override-tsconfig-ngc.json
99 | ```
100 |
101 | # Authors and Contributors
102 |
103 | @bmvantunes (Bruno Antunes, author)
104 |
105 | Special thanks to [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template). Without [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template) `angular-library-builder` would not be possible!
106 |
107 | # License
108 |
109 | The repository code is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
110 |
--------------------------------------------------------------------------------
/test/fixtures/basic-html-no-css-with-spec-files/output-expected/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/bmvantunes/angular-library-builder)
2 | [](https://david-dm.org/bmvantunes/angular-library-builder)
3 | [](https://david-dm.org/bmvantunes/angular-library-builder?type=dev)
4 | [](https://github.com/semantic-release/semantic-release)
5 | [](https://badge.fury.io/js/angular-library-builder)
6 | [](https://codecov.io/gh/bmvantunes/angular-library-builder)
7 | [](http://commitizen.github.io/cz-cli/)
8 | [](https://greenkeeper.io/)
9 |
10 | # What is Angular Library Builder (nglb)?
11 |
12 | It's a CLI Tool to build Angular (2+) libraries ready to be published to [npm](https://www.npmjs.com/).
13 |
14 | ### What problem is Angular Library Builder (nglb) trying to solve?
15 |
16 | At the moment there is no official documentation/guidelines on how to build and publish Angular (2+) components/libraries/services/modules to npm. Angular Library Builder (nglb) is trying to solve this in the easiest way possible.
17 |
18 | ### How does Angular Library Builder (nglb) solve this?
19 |
20 | 1. If it is a component, inlines html template file into the component as a string, replacing `templateUrl` with `template`
21 | - In the inlining process nglb also minifies html using [html-minifier](https://www.npmjs.com/package/html-minifier)
22 | 2. If it is a component, inlines scss/sass/css file(s) into the component as a string, replacing `stylesUrls` with `styles`. It uses:
23 | - [node-sass](https://www.npmjs.com/package/node-sass) to compile scss/sass file(s)
24 | - [autoprefixer](https://www.npmjs.com/package/autoprefixer) to improve browser compatibilty
25 | - [csso](https://www.npmjs.com/package/csso) to minimize/optimize your css
26 | 3. Finally, it compiles your resulting typescript files with all your html and css inlined, using @angular/compiler-cli (ngc), creating `*.d.ts`, `*.js`, `*.js.map`, `*.metadata.json` files
27 |
28 | # Getting Started
29 |
30 | #### Install the `angular-library-builder` command
31 |
32 | ```sh
33 | npm install --save-dev angular-library-builder
34 | ```
35 |
36 | #### How to use `angular-library-builder`?
37 |
38 | Add angular-library-builder (nglb) script, main and types to `package.json`:
39 |
40 | ```json
41 | "main": "./lib-dist/your-main-file.js",
42 | "types": "./lib-dist/your-main-file.d.ts",
43 | "scripts": {
44 | "build:library": "nglb --rootDir src/lib --outDir lib-dist"
45 | }
46 | ```
47 | or
48 | ```json
49 | "main": "./lib-dist/your-main-file.js",
50 | "types": "./lib-dist/your-main-file.d.ts",
51 | "scripts": {
52 | "build:library": "angular-library-builder --rootDir src/lib --outDir lib-dist"
53 | }
54 | ```
55 |
56 | Now, in your project root:
57 | ```sh
58 | npm run build:library
59 | ```
60 |
61 | Congratulations! Your library is available in lib-dist folder ready to be published to npm.
62 |
63 | To publish your new library to npm, execute the following command in your project root:
64 | ```sh
65 | npm publish
66 | ```
67 |
68 | #### Options that `angular-library-builder` supports
69 | option (argument) | description
70 | ------------ | -------------
71 | --rootDir | Specifies the root directory of input files. Example: ```nglb --rootDir src```, [required]
72 | --outDir | Redirect output structure to the directory. Example: ```nglb --outDir dist```, [required]
73 | --tsconfig | Possibility to extend/override properties in default [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json). Example: ```nglb --tsconfig path/to/your/override-tsconfig-ngc.json```
74 | --help (-h) | Print help message
75 |
76 |
77 | # How to change `angular-library-builder` [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json) default properties?
78 | Sometimes the defaults aren't good enough for everybody.
79 |
80 | #### Example
81 | Let's imagine that you want to change slightly the build process:
82 | 1. change the default "target" from "es5" to "es2015"
83 | 2. add a new property, for example, "noImplicitAny": true,
84 |
85 | To acomplish this create a file called, for example, ```override-tsconfig-ngc.json``` in your project root.
86 | Your ```override-tsconfig-ngc.json``` file can be something like:
87 | ```json
88 | {
89 | "compilerOptions": {
90 | "target": "es2015",
91 | "noImplicitAny": true
92 | }
93 | }
94 | ```
95 |
96 | Then, you invoke nglb like this:
97 | ```bash
98 | nglb --rootDir path/to/your/source --outDir path/to/dist --tsconfig override-tsconfig-ngc.json
99 | ```
100 |
101 | # Authors and Contributors
102 |
103 | @bmvantunes (Bruno Antunes, author)
104 |
105 | Special thanks to [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template). Without [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template) `angular-library-builder` would not be possible!
106 |
107 | # License
108 |
109 | The repository code is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
110 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ⛔️ [DEPRECATED] - @angular/cli version 6.0.0 has support for libraries
2 |
3 | [](https://travis-ci.org/bmvantunes/angular-library-builder)
4 | [](https://david-dm.org/bmvantunes/angular-library-builder)
5 | [](https://david-dm.org/bmvantunes/angular-library-builder?type=dev)
6 | [](https://github.com/semantic-release/semantic-release)
7 | [](https://badge.fury.io/js/angular-library-builder)
8 | [](https://codecov.io/gh/bmvantunes/angular-library-builder)
9 | [](http://commitizen.github.io/cz-cli/)
10 | [](https://greenkeeper.io/)
11 |
12 | # What is Angular Library Builder (nglb)?
13 |
14 | It's a CLI Tool to build Angular (2+) libraries ready to be published to [npm](https://www.npmjs.com/).
15 |
16 | ### What problem is Angular Library Builder (nglb) trying to solve?
17 |
18 | At the moment there is no official documentation/guidelines on how to build and publish Angular (2+) components/libraries/services/modules to npm. Angular Library Builder (nglb) is trying to solve this in the easiest way possible.
19 |
20 | ### How does Angular Library Builder (nglb) solve this?
21 |
22 | 1. If it is a component, inlines html template file into the component as a string, replacing `templateUrl` with `template`
23 | - In the inlining process nglb also minifies html using [html-minifier](https://www.npmjs.com/package/html-minifier)
24 | 2. If it is a component, inlines scss/sass/css file(s) into the component as a string, replacing `stylesUrls` with `styles`. It uses:
25 | - [node-sass](https://www.npmjs.com/package/node-sass) to compile scss/sass file(s)
26 | - [autoprefixer](https://www.npmjs.com/package/autoprefixer) to improve browser compatibilty
27 | - [csso](https://www.npmjs.com/package/csso) to minimize/optimize your css
28 | 3. Finally, it compiles your resulting typescript files with all your html and css inlined, using @angular/compiler-cli (ngc), creating `*.d.ts`, `*.js`, `*.js.map`, `*.metadata.json` files
29 |
30 | # Getting Started
31 |
32 | #### Install the `angular-library-builder` command
33 |
34 | ```sh
35 | npm install --save-dev angular-library-builder
36 | ```
37 |
38 | #### How to use `angular-library-builder`?
39 |
40 | Add angular-library-builder (nglb) script, main and types to `package.json`:
41 |
42 | ```json
43 | "main": "./lib-dist/your-main-file.js",
44 | "types": "./lib-dist/your-main-file.d.ts",
45 | "scripts": {
46 | "build:library": "nglb --rootDir src/lib --outDir lib-dist"
47 | }
48 | ```
49 | or
50 | ```json
51 | "main": "./lib-dist/your-main-file.js",
52 | "types": "./lib-dist/your-main-file.d.ts",
53 | "scripts": {
54 | "build:library": "angular-library-builder --rootDir src/lib --outDir lib-dist"
55 | }
56 | ```
57 |
58 | Now, in your project root:
59 | ```sh
60 | npm run build:library
61 | ```
62 |
63 | Congratulations! Your library is available in lib-dist folder ready to be published to npm.
64 |
65 | To publish your new library to npm, execute the following command in your project root:
66 | ```sh
67 | npm publish
68 | ```
69 |
70 | #### Options that `angular-library-builder` supports
71 | option (argument) | description
72 | ------------ | -------------
73 | --rootDir | Specifies the root directory of input files. Example: ```nglb --rootDir src```, [required]
74 | --outDir | Redirect output structure to the directory. Example: ```nglb --outDir dist```, [required]
75 | --tsconfig | Possibility to extend/override properties in default [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json). Example: ```nglb --tsconfig path/to/your/override-tsconfig-ngc.json```
76 | --help (-h) | Print help message
77 |
78 |
79 | # How to change `angular-library-builder` [tsconfig-ngc.json](https://github.com/bmvantunes/angular-library-builder/blob/master/tsconfig-ngc.json) default properties?
80 | Sometimes the defaults aren't good enough for everybody.
81 |
82 | #### Example
83 | Let's imagine that you want to change slightly the build process:
84 | 1. change the default "target" from "es5" to "es2015"
85 | 2. add a new property, for example, "noImplicitAny": true,
86 |
87 | To acomplish this create a file called, for example, ```override-tsconfig-ngc.json``` in your project root.
88 | Your ```override-tsconfig-ngc.json``` file can be something like:
89 | ```json
90 | {
91 | "compilerOptions": {
92 | "target": "es2015",
93 | "noImplicitAny": true
94 | }
95 | }
96 | ```
97 |
98 | Then, you invoke nglb like this:
99 | ```bash
100 | nglb --rootDir path/to/your/source --outDir path/to/dist --tsconfig override-tsconfig-ngc.json
101 | ```
102 |
103 | # Authors and Contributors
104 |
105 | @bmvantunes (Bruno Antunes, author)
106 |
107 | Special thanks to [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template). Without [gulp-inline-ng2-template](https://github.com/ludohenin/gulp-inline-ng2-template) `angular-library-builder` would not be possible!
108 |
109 | # License
110 |
111 | The repository code is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
112 |
--------------------------------------------------------------------------------