@ng-toolkit/serverless
Advanced tools
Comparing version 1.1.16 to 1.1.18
{ | ||
"author": "Maciej Treder <contact@maciejtreder.com>", | ||
"name": "@ng-toolkit/serverless", | ||
"version": "1.1.16", | ||
"version": "1.1.18", | ||
"description": "Angular Universal PWA boilerplate for serverless environment.", | ||
@@ -34,3 +34,3 @@ "repository": { | ||
"@angular-devkit/schematics": "^0.6.3", | ||
"@ng-toolkit/_utils": "^1.1.16", | ||
"@ng-toolkit/_utils": "^1.1.18", | ||
"@schematics/angular": "^0.6.3", | ||
@@ -40,2 +40,3 @@ "bugsnag": "^2.3.1" | ||
"devDependencies": { | ||
"@ng-toolkit/universal": "1.1.18", | ||
"@types/jasmine": "^2.6.0", | ||
@@ -42,0 +43,0 @@ "@types/node": "^8.10.17", |
@@ -1,69 +0,207 @@ | ||
// import * as path from 'path'; | ||
// import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; | ||
// | ||
// const collectionPath = path.join(__dirname, '../collection.json'); | ||
// | ||
// xdescribe('my-component', () => { | ||
// console.log(collectionPath); | ||
// const prerequisiteRunner = new SchematicTestRunner('@schematics/angular', collectionPath); | ||
// | ||
// const schematicRunner = new SchematicTestRunner('@ng-toolkit/serverless', collectionPath); | ||
// | ||
// const defaultOptions = { | ||
// name: 'foo', | ||
// inlineStyle: false, | ||
// inlineTemplate: false, | ||
// routing: false, | ||
// style: 'css', | ||
// skipTests: false, | ||
// skipPackageJson: false, | ||
// version: '6.0.0' | ||
// }; | ||
// | ||
// let workspaceTree: UnitTestTree; | ||
// beforeEach(() => { | ||
// console.log('beforeach'); | ||
// workspaceTree = prerequisiteRunner.runSchematic('ng-new', {...defaultOptions}); | ||
// console.log('runned schematics'); | ||
// console.log(workspaceTree.files); | ||
// }); | ||
// | ||
// it('should create all files of an application', () => { | ||
// const options = { ...defaultOptions }; | ||
// const tree = schematicRunner.runSchematic('ng-add', options, workspaceTree); | ||
// const files = tree.files; | ||
// | ||
// checkIfFileExists(files,'/foo/tsconfig.json'); | ||
// checkIfFileExists(files,'/foo/tslint.json'); | ||
// checkIfFileExists(files,'/foo/angular.json'); | ||
// checkIfFileExists(files,'/foo/credentials.js'); | ||
// checkIfFileExists(files,'/foo/LICENSE'); | ||
// checkIfFileExists(files,'/foo/local.js'); | ||
// checkIfFileExists(files,'/foo/ngsw-config.json'); | ||
// checkIfFileExists(files,'/foo/postinstall.js'); | ||
// checkIfFileExists(files,'/foo/README.md'); | ||
// checkIfFileExists(files,'/foo/src/environments/environment.ts'); | ||
// checkIfFileExists(files,'/foo/src/environments/environment.prod.ts'); | ||
// checkIfFileExists(files,'/foo/src/favicon.ico'); | ||
// checkIfFileExists(files,'/foo/src/index.html'); | ||
// checkIfFileExists(files,'/foo/src/main.browser.ts'); | ||
// checkIfFileExists(files,'/foo/src/manifest.json'); | ||
// checkIfFileExists(files,'/foo/src/main.server.ts'); | ||
// checkIfFileExists(files,'/foo/src/polyfills.ts'); | ||
// checkIfFileExists(files,'/foo/src/styles.css'); | ||
// checkIfFileExists(files,'/foo/src/test.ts'); | ||
// checkIfFileExists(files,'/foo/src/tsconfig.app.json'); | ||
// checkIfFileExists(files,'/foo/src/tsconfig.server.json'); | ||
// checkIfFileExists(files,'/foo/src/tsconfig.spec.json'); | ||
// checkIfFileExists(files,'/foo/src/app/app.module.ts'); | ||
// checkIfFileExists(files,'/foo/src/app/app.component.css'); | ||
// checkIfFileExists(files,'/foo/src/app/app.component.html'); | ||
// checkIfFileExists(files,'/foo/src/app/app.component.spec.ts'); | ||
// checkIfFileExists(files,'/foo/src/app/app.component.ts'); | ||
// }); | ||
// }); | ||
// | ||
// function checkIfFileExists(files: string[], fileName: string) { | ||
// expect(files.indexOf(fileName)).toBeGreaterThanOrEqual(0, `Lack of ${fileName}`); | ||
// } | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const path = require("path"); | ||
const testing_1 = require("@angular-devkit/schematics/testing"); | ||
const testing_2 = require("@ng-toolkit/_utils/testing"); | ||
const schematics_1 = require("@angular-devkit/schematics"); | ||
const collectionPath = path.join(__dirname, '../collection.json'); | ||
describe('Serverless', () => { | ||
let appTree; | ||
const schematicRunner = new testing_1.SchematicTestRunner('@ng-toolkit/serverless', collectionPath); | ||
const defaultOptions = { | ||
project: 'foo', | ||
disableBugsnag: true, | ||
directory: '/foo' | ||
}; | ||
const appOptions = { | ||
name: 'foo', | ||
version: '6.0.0', | ||
}; | ||
beforeEach((done) => { | ||
appTree = new testing_1.UnitTestTree(schematics_1.Tree.empty()); | ||
schematicRunner.runExternalSchematicAsync('@schematics/angular', 'ng-new', appOptions, appTree).subscribe(tree => { | ||
appTree = tree; | ||
done(); | ||
}); | ||
}); | ||
describe('AWS Lambda', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'aws'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create serverless configuration for AWS', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/lambda.js`); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\saws/); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \/production\/"/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('Firebase', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'firebase'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create files', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/functions/package.json`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/functions/index.js`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/.firebaserc`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/firebase.json`); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \//); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('Google Cloud Functions', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'gcloud'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create serverless configuration and files', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/index.js`); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\sgoogle/); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \/http\/"/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('By default AWS should be choosen as provider', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/lambda.js`); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\saws/); | ||
done(); | ||
}); | ||
}); | ||
it('Should create all common files', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/local.js`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/server.ts`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/webpack.server.config.js`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/ng-toolkit.json`); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:prod": "ng build --prod"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:prod": "npm run build:browser:prod && npm run build:server:prod"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"server": "node local.js"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:prod:deploy": "npm run build:prod && npm run deploy"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:server:prod": "webpack --config webpack.server.config.js --progress --colors"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:serverless": "npm run build:browser:serverless && npm run build:server:serverless"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:serverless:deploy": "npm run build:serverless && npm run deploy"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:server:serverless": "webpack --config webpack.server.config.js --progress --colors"/); | ||
done(); | ||
}); | ||
}); | ||
describe('After Universal', () => { | ||
beforeEach((done) => { | ||
schematicRunner.runExternalSchematicAsync('@ng-toolkit/universal', 'ng-add', defaultOptions, appTree).subscribe(tree => { | ||
appTree = tree; | ||
done(); | ||
}); | ||
}); | ||
describe('AWS Lambda', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'aws'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create serverless configuration for AWS', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/lambda.js`); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\saws/); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \/production\/"/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('Firebase', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'firebase'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create files', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/functions/package.json`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/functions/index.js`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/.firebaserc`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/firebase.json`); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \//); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('Google Cloud Functions', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'gcloud'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create serverless configuration and files', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/index.js`); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\sgoogle/); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \/http\/"/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('By default AWS should be choosen as provider', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/lambda.js`); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\saws/); | ||
done(); | ||
}); | ||
}); | ||
it('Should create all common files', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/local.js`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/server.ts`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/webpack.server.config.js`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/ng-toolkit.json`); | ||
testing_2.checkIfFileExists(tree, `${defaultOptions.directory}/src/environments/environment.serverless.ts`); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:prod": "ng build --prod"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:prod": "npm run build:browser:prod && npm run build:server:prod"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"server": "node local.js"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:prod:deploy": "npm run build:prod && npm run deploy"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:server:prod": "ng run foo:server && webpack --config webpack.server.config.js --progress --colors"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:serverless": "npm run build:browser:serverless && npm run build:server:serverless"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:serverless:deploy": "npm run build:serverless && npm run deploy"/); | ||
testing_2.shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:server:serverless": "ng run foo:server:serverless && webpack --config webpack.server.config.js --progress --colors"/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=index_spec.js.map |
@@ -1,68 +0,231 @@ | ||
// import * as path from 'path'; | ||
// import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; | ||
// | ||
// const collectionPath = path.join(__dirname, '../collection.json'); | ||
// | ||
// xdescribe('my-component', () => { | ||
// console.log(collectionPath); | ||
// const prerequisiteRunner = new SchematicTestRunner('@schematics/angular', collectionPath); | ||
// | ||
// const schematicRunner = new SchematicTestRunner('@ng-toolkit/serverless', collectionPath); | ||
// | ||
// const defaultOptions = { | ||
// name: 'foo', | ||
// inlineStyle: false, | ||
// inlineTemplate: false, | ||
// routing: false, | ||
// style: 'css', | ||
// skipTests: false, | ||
// skipPackageJson: false, | ||
// version: '6.0.0' | ||
// }; | ||
// | ||
// let workspaceTree: UnitTestTree; | ||
// beforeEach(() => { | ||
// console.log('beforeach'); | ||
// workspaceTree = prerequisiteRunner.runSchematic('ng-new', {...defaultOptions}); | ||
// console.log('runned schematics'); | ||
// console.log(workspaceTree.files); | ||
// }); | ||
// | ||
// it('should create all files of an application', () => { | ||
// const options = { ...defaultOptions }; | ||
// const tree = schematicRunner.runSchematic('ng-add', options, workspaceTree); | ||
// const files = tree.files; | ||
// | ||
// checkIfFileExists(files,'/foo/tsconfig.json'); | ||
// checkIfFileExists(files,'/foo/tslint.json'); | ||
// checkIfFileExists(files,'/foo/angular.json'); | ||
// checkIfFileExists(files,'/foo/credentials.js'); | ||
// checkIfFileExists(files,'/foo/LICENSE'); | ||
// checkIfFileExists(files,'/foo/local.js'); | ||
// checkIfFileExists(files,'/foo/ngsw-config.json'); | ||
// checkIfFileExists(files,'/foo/postinstall.js'); | ||
// checkIfFileExists(files,'/foo/README.md'); | ||
// checkIfFileExists(files,'/foo/src/environments/environment.ts'); | ||
// checkIfFileExists(files,'/foo/src/environments/environment.prod.ts'); | ||
// checkIfFileExists(files,'/foo/src/favicon.ico'); | ||
// checkIfFileExists(files,'/foo/src/index.html'); | ||
// checkIfFileExists(files,'/foo/src/main.browser.ts'); | ||
// checkIfFileExists(files,'/foo/src/manifest.json'); | ||
// checkIfFileExists(files,'/foo/src/main.server.ts'); | ||
// checkIfFileExists(files,'/foo/src/polyfills.ts'); | ||
// checkIfFileExists(files,'/foo/src/styles.css'); | ||
// checkIfFileExists(files,'/foo/src/test.ts'); | ||
// checkIfFileExists(files,'/foo/src/tsconfig.app.json'); | ||
// checkIfFileExists(files,'/foo/src/tsconfig.server.json'); | ||
// checkIfFileExists(files,'/foo/src/tsconfig.spec.json'); | ||
// checkIfFileExists(files,'/foo/src/app/app.module.ts'); | ||
// checkIfFileExists(files,'/foo/src/app/app.component.css'); | ||
// checkIfFileExists(files,'/foo/src/app/app.component.html'); | ||
// checkIfFileExists(files,'/foo/src/app/app.component.spec.ts'); | ||
// checkIfFileExists(files,'/foo/src/app/app.component.ts'); | ||
// }); | ||
// }); | ||
// | ||
// function checkIfFileExists(files: string[], fileName: string) { | ||
// expect(files.indexOf(fileName)).toBeGreaterThanOrEqual(0, `Lack of ${fileName}`); | ||
// } | ||
import * as path from 'path'; | ||
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing'; | ||
import { checkIfFileExists, shouldContainEntry } from '@ng-toolkit/_utils/testing'; | ||
import { Tree } from '@angular-devkit/schematics'; | ||
const collectionPath = path.join(__dirname, '../collection.json'); | ||
describe('Serverless', () => { | ||
let appTree: UnitTestTree; | ||
const schematicRunner = new SchematicTestRunner('@ng-toolkit/serverless', collectionPath); | ||
const defaultOptions: any = { | ||
project: 'foo', | ||
disableBugsnag: true, | ||
directory: '/foo' | ||
}; | ||
const appOptions: any = { | ||
name: 'foo', | ||
version: '6.0.0', | ||
}; | ||
beforeEach((done) => { | ||
appTree = new UnitTestTree(Tree.empty()); | ||
schematicRunner.runExternalSchematicAsync('@schematics/angular', 'ng-new', appOptions, appTree).subscribe(tree => { | ||
appTree = tree | ||
done(); | ||
}); | ||
}); | ||
describe('AWS Lambda', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'aws'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create serverless configuration for AWS', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/lambda.js`); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\saws/); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \/production\/"/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('Firebase', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'firebase'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create files', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
checkIfFileExists(tree, `${defaultOptions.directory}/functions/package.json`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/functions/index.js`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/.firebaserc`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/firebase.json`); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \//); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('Google Cloud Functions', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'gcloud'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create serverless configuration and files', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/index.js`); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\sgoogle/); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \/http\/"/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('By default AWS should be choosen as provider', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/lambda.js`); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\saws/); | ||
done(); | ||
}); | ||
}); | ||
it('Should create all common files', (done)=> { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
checkIfFileExists(tree, `${defaultOptions.directory}/local.js`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/server.ts`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/webpack.server.config.js`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/ng-toolkit.json`); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:prod": "ng build --prod"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:prod": "npm run build:browser:prod && npm run build:server:prod"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"server": "node local.js"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:prod:deploy": "npm run build:prod && npm run deploy"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:server:prod": "webpack --config webpack.server.config.js --progress --colors"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:serverless": "npm run build:browser:serverless && npm run build:server:serverless"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:serverless:deploy": "npm run build:serverless && npm run deploy"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:server:serverless": "webpack --config webpack.server.config.js --progress --colors"/); | ||
done(); | ||
}); | ||
}); | ||
describe('After Universal', () => { | ||
beforeEach((done) => { | ||
schematicRunner.runExternalSchematicAsync('@ng-toolkit/universal', 'ng-add', defaultOptions, appTree).subscribe(tree => { | ||
appTree = tree; | ||
done(); | ||
}); | ||
}); | ||
describe('AWS Lambda', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'aws'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create serverless configuration for AWS', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/lambda.js`); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\saws/); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \/production\/"/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('Firebase', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'firebase'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create files', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
checkIfFileExists(tree, `${defaultOptions.directory}/functions/package.json`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/functions/index.js`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/.firebaserc`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/firebase.json`); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \//); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('Google Cloud Functions', () => { | ||
beforeAll(() => defaultOptions['provider'] = 'gcloud'); | ||
afterAll(() => delete defaultOptions['provider']); | ||
it('Should create serverless configuration and files', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/index.js`); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\sgoogle/); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:serverless": "ng build --prod --base-href \/http\/"/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('By default AWS should be choosen as provider', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
checkIfFileExists(tree, `${defaultOptions.directory}/serverless.yml`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/lambda.js`); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/serverless.yml`, /provider:[\s\S]*name:\saws/); | ||
done(); | ||
}); | ||
}); | ||
it('Should create all common files', (done)=> { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
checkIfFileExists(tree, `${defaultOptions.directory}/local.js`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/server.ts`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/webpack.server.config.js`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/ng-toolkit.json`); | ||
checkIfFileExists(tree, `${defaultOptions.directory}/src/environments/environment.serverless.ts`); | ||
done(); | ||
}); | ||
}); | ||
it('Should add proper scripts to package.json', (done) => { | ||
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).subscribe(tree => { | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:browser:prod": "ng build --prod"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:prod": "npm run build:browser:prod && npm run build:server:prod"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"server": "node local.js"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:prod:deploy": "npm run build:prod && npm run deploy"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:server:prod": "ng run foo:server && webpack --config webpack.server.config.js --progress --colors"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:serverless": "npm run build:browser:serverless && npm run build:server:serverless"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:serverless:deploy": "npm run build:serverless && npm run deploy"/); | ||
shouldContainEntry(tree, `${defaultOptions.directory}/package.json`, /"build:server:serverless": "ng run foo:server:serverless && webpack --config webpack.server.config.js --progress --colors"/); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -26,2 +26,4 @@ "use strict"; | ||
rules.push((tree, context) => { | ||
// update project name | ||
_utils_1.updateProject(tree, options); | ||
const ngToolkitSettings = _utils_1.getNgToolkitInfo(tree, options); | ||
@@ -153,3 +155,8 @@ if (!ngToolkitSettings.universal) { | ||
}); | ||
return _utils_1.applyAndLog(schematics_1.chain(rules)); | ||
if (!options.disableBugsnag) { | ||
return _utils_1.applyAndLog(schematics_1.chain(rules)); | ||
} | ||
else { | ||
return schematics_1.chain(rules); | ||
} | ||
} | ||
@@ -156,0 +163,0 @@ exports.default = addServerless; |
@@ -6,3 +6,4 @@ import { | ||
applyAndLog, addDependencyToPackageJson, addOrReplaceScriptInPackageJson, addOpenCollective, updateGitIgnore, | ||
createOrOverwriteFile, addEntryToEnvironment, getMethodBody, updateMethod, addMethod, addImportStatement, getDistFolder, isUniversal, getBrowserDistFolder, getServerDistFolder, implementInterface, addParamterToMethod, getNgToolkitInfo, updateNgToolkitInfo | ||
createOrOverwriteFile, addEntryToEnvironment, getMethodBody, updateMethod, addMethod, addImportStatement, getDistFolder, | ||
isUniversal, getBrowserDistFolder, getServerDistFolder, implementInterface, addParamterToMethod, getNgToolkitInfo, updateNgToolkitInfo, updateProject | ||
} from '@ng-toolkit/_utils'; | ||
@@ -37,2 +38,5 @@ import { getFileContent } from '@schematics/angular/utility/test'; | ||
rules.push((tree: Tree, context: SchematicContext) => { | ||
// update project name | ||
updateProject(tree, options); | ||
const ngToolkitSettings = getNgToolkitInfo(tree, options); | ||
@@ -182,3 +186,7 @@ if (!ngToolkitSettings.universal) { | ||
}); | ||
return applyAndLog(chain(rules)); | ||
if (!options.disableBugsnag) { | ||
return applyAndLog(chain(rules)); | ||
} else { | ||
return chain(rules); | ||
} | ||
} | ||
@@ -185,0 +193,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
187351
1292
6
Updated@ng-toolkit/_utils@^1.1.18