-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(component): make Angular 9.0.0 a supported peer dependency
closes #168
- Loading branch information
Showing
51 changed files
with
9,131 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { examples, Example } from './examples'; | ||
import { execSync } from "child_process"; | ||
import * as fs from 'fs'; | ||
|
||
examples.forEach(buildExample) | ||
execSync('rm -rf ../dist/ng-recaptcha/v9-temp', { stdio: 'inherit' }) | ||
|
||
function buildExample(example: Example) { | ||
if (example.additional) { | ||
// FIXME "ng build" supports multiple entry points out of the box. | ||
// However, that should be possible. And once we figure out how to do this properly, | ||
// this function should also generate resources for such examples | ||
return; | ||
} | ||
|
||
const indexFileName = example.index ? 'index.html' : example.name + '.html'; | ||
|
||
if (!fs.existsSync(`src/${indexFileName}`)) { | ||
fs.copyFileSync('src/index.html', `src/${indexFileName}`); | ||
} | ||
|
||
const angularSettings = JSON.parse(fs.readFileSync('./angular.json', { encoding: 'utf-8' })); | ||
angularSettings.projects.v9.architect.build.options.outputPath = `../dist/ng-recaptcha/v9-temp`; | ||
angularSettings.projects.v9.architect.build.options.index = `src/${indexFileName}`; | ||
angularSettings.projects.v9.architect.build.options.main = `src/app/examples/${example.name}/${example.name}-demo.main.ts`; | ||
fs.writeFileSync('./angular.json', JSON.stringify(angularSettings, null, 2), { encoding: 'utf-8' }); | ||
|
||
const tsConfig = JSON.parse(fs.readFileSync('./tsconfig.app.json', { encoding: 'utf-8' })); | ||
tsConfig.files = [ | ||
`src/app/examples/${example.name}/${example.name}-demo.main.ts`, | ||
"src/polyfills.ts" | ||
]; | ||
fs.writeFileSync('./tsconfig.app.json', JSON.stringify(tsConfig, null, 2), { encoding: 'utf-8' }); | ||
|
||
|
||
execSync('yarn ng-build', { stdio: 'inherit' }); | ||
execSync('cp -R ../dist/ng-recaptcha/v9-temp/ ../dist/ng-recaptcha', { stdio: 'inherit' }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { examples } from './examples'; | ||
|
||
const sourceDir = path.join(process.cwd(), 'src'); | ||
|
||
function writeExampleFile(featureName, fileName, contents) { | ||
const location = path.join(sourceDir, 'app', 'examples', featureName, fileName); | ||
|
||
fs.writeFileSync(location, contents, { encoding: 'UTF8' }); | ||
} | ||
|
||
function highlightRequire(file: string, lang: string) { | ||
var hl = require('highlight.js'); | ||
var highlightAuto = hl.highlightAuto; | ||
var highlight = hl.highlight; | ||
|
||
const data = JSON.stringify(highlightCode(fs.readFileSync(file, { encoding: 'utf-8' }), lang)) | ||
|
||
function highlightCode(code: string, lang: string | undefined) { | ||
if(lang) { | ||
return highlight(lang, code).value; | ||
} | ||
|
||
return highlightAuto(code).value; | ||
} | ||
|
||
return data; | ||
} | ||
|
||
function generateMain(featureName) { | ||
const contents = `import { enableProdMode } from '@angular/core'; | ||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; | ||
import { DemoModule } from './${featureName}-demo.module'; | ||
enableProdMode(); | ||
platformBrowserDynamic().bootstrapModule(DemoModule); | ||
`; | ||
|
||
writeExampleFile(featureName, `${featureName}-demo.main.ts`, contents); | ||
} | ||
|
||
function generateData(example) { | ||
const featureName = example.name; | ||
const additionalContents = !example.additional ? '' : ` | ||
additional: { | ||
content: ${highlightRequire(`./src/app/examples/${featureName}/${example.additional.filename}.ts`, example.additional.type)}, | ||
title: '${example.additional.title}', | ||
type: '${example.additional.type}', | ||
},`; | ||
const contents = `// tslint:disable no-require-imports no-submodule-imports | ||
import { PageSettings } from '../../demo-wrapper/demo-wrapper.component'; | ||
export const settings: PageSettings = { | ||
feature: '${featureName}', | ||
title: '${example.title}', | ||
content: { | ||
component: ${highlightRequire(`./src/app/examples/${featureName}/${featureName}-demo.component.ts`, 'ts')}, | ||
html: ${highlightRequire(`./src/app/examples/${featureName}/${featureName}-demo.component.html`, 'html')}, | ||
module: ${highlightRequire(`./src/app/examples/${featureName}/${featureName}-demo.module.ts`, 'ts')},${additionalContents} | ||
}, | ||
}; | ||
`; | ||
|
||
writeExampleFile(featureName, `${featureName}-demo.data.ts`, contents); | ||
} | ||
|
||
function generateLinks() { | ||
const location = path.join(sourceDir, 'app', 'demo-wrapper', 'demo-wrapper.data.auto-gen.ts'); | ||
const contents = `export const navLinks = [ | ||
${examples.filter(e => !e.additional).map((e) => `{ | ||
label: '${e.label}', | ||
path: '${e.path}', | ||
feature: '${e.name}', | ||
},`).join('\n ')} | ||
]; | ||
`; | ||
|
||
fs.writeFileSync(location, contents, { encoding: 'UTF8' }); | ||
} | ||
|
||
function generateFiles() { | ||
examples.map((e) => e.name).forEach(generateMain); | ||
examples.forEach(generateData); | ||
generateLinks(); | ||
} | ||
|
||
generateFiles(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/* | ||
!yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"version": 1, | ||
"newProjectRoot": "projects", | ||
"projects": { | ||
"v9": { | ||
"projectType": "application", | ||
"schematics": {}, | ||
"root": "", | ||
"sourceRoot": "src", | ||
"prefix": "app", | ||
"architect": { | ||
"build": { | ||
"builder": "@angular-devkit/build-angular:browser", | ||
"options": { | ||
"outputPath": "../dist/ng-recaptcha", | ||
"index": "src/index.html", | ||
"main": "src/app/examples/basic/basic-demo.main.ts", | ||
"polyfills": "src/polyfills.ts", | ||
"tsConfig": "tsconfig.app.json", | ||
"outputHashing": "all", | ||
"aot": true, | ||
"assets": [ | ||
"src/favicon.ico", | ||
"src/images" | ||
], | ||
"styles": [ | ||
"src/styles.css" | ||
], | ||
"scripts": [] | ||
}, | ||
"configurations": { | ||
"production": { | ||
"fileReplacements": [], | ||
"optimization": true, | ||
"outputHashing": "all", | ||
"sourceMap": false, | ||
"extractCss": true, | ||
"namedChunks": false, | ||
"extractLicenses": true, | ||
"vendorChunk": false, | ||
"buildOptimizer": true, | ||
"budgets": [ | ||
{ | ||
"type": "initial", | ||
"maximumWarning": "2mb", | ||
"maximumError": "5mb" | ||
}, | ||
{ | ||
"type": "anyComponentStyle", | ||
"maximumWarning": "6kb", | ||
"maximumError": "10kb" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
}}, | ||
"defaultProject": "v9" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. | ||
# For additional information regarding the format and rule options, please see: | ||
# https://github.com/browserslist/browserslist#queries | ||
|
||
# You can see what browsers were selected by your queries by running: | ||
# npx browserslist | ||
|
||
> 0.5% | ||
last 2 versions | ||
Firefox ESR | ||
not dead | ||
not IE 9-11 # For IE 9-11 support, remove 'not'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "v9", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"file-gen": "ts-node ./bin/file-gen-v9.ts", | ||
"latest": "yarn remove ng-recaptcha; yarn install; yarn add ng-recaptcha@../../ng-recaptcha-latest.tgz --update-checksums", | ||
"clean": "rimraf src/app/examples/**/*{-demo.main.ts,-demo.data.ts}", | ||
"serve": "http-server ./dist -a localhost -p 9000 -c-1", | ||
"start": "run-s build-dev serve", | ||
"ng-build": "ng build", | ||
"build": "yarn latest && run-s clean file-gen webpack:prod", | ||
"webpack:prod": "ts-node ./bin/build-v9.ts" | ||
}, | ||
"private": true, | ||
"dependencies": { | ||
"@angular/animations": "~9.1.12", | ||
"@angular/cdk": "^9.0.0", | ||
"@angular/common": "~9.1.12", | ||
"@angular/compiler": "~9.1.12", | ||
"@angular/core": "~9.1.12", | ||
"@angular/forms": "~9.1.12", | ||
"@angular/material": "^9.0.0", | ||
"@angular/platform-browser": "~9.1.12", | ||
"@angular/platform-browser-dynamic": "~9.1.12", | ||
"@angular/router": "~9.1.12", | ||
"ng-recaptcha": "../../ng-recaptcha-latest.tgz", | ||
"rxjs": "~6.5.4", | ||
"tslib": "^1.10.0", | ||
"zone.js": "~0.10.2" | ||
}, | ||
"devDependencies": { | ||
"@angular-devkit/build-angular": "~0.901.12", | ||
"@angular/cli": "~9.1.12", | ||
"@angular/compiler-cli": "~9.1.12", | ||
"@types/node": "^12.11.1", | ||
"highlight.js": "^10.1.1", | ||
"npm-run-all": "^4.1.2", | ||
"rimraf": "^2.6.3", | ||
"ts-node": "~8.3.0", | ||
"typescript": "~3.8.3" | ||
} | ||
} |
Oops, something went wrong.