This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch created for Runtime widget support
- Loading branch information
1 parent
171dbae
commit 02bdd24
Showing
10 changed files
with
4,077 additions
and
560 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,12 @@ | ||
{ | ||
"name": "Event Chart Runtime Widget", | ||
"contextPath": "event-chart-runtime-widget", | ||
"key": "event-chart-runtime-widget-application-key", | ||
"contentSecurityPolicy": "default-src 'self'", | ||
"icon": { | ||
"class": "fa fa-puzzle-piece" | ||
}, | ||
"manifest": { | ||
"noAppSwitcher": true | ||
} | ||
} |
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,48 @@ | ||
const {src, dest, series} = require('gulp'); | ||
const filter = require('gulp-filter'); | ||
const zip = require('gulp-zip'); | ||
const ngPackagr = require('ng-packagr'); | ||
const fs = require('fs-extra'); | ||
const del = require('del'); | ||
const execSync = require('child_process').execSync; | ||
const replace = require('gulp-replace'); | ||
const path = require('path'); | ||
|
||
function clean() { | ||
return del(['dist']); | ||
} | ||
|
||
const compile = series( | ||
function buildAngularLibrary() { return ngPackagr.build({project: './ng-package.json'}) }, | ||
function separateWebpackBuildSrc() { return fs.copy('./dist/widget-library/fesm5', './dist/bundle-src') }, | ||
function replaceStylePath() { | ||
return src('./dist/widget-library/**/*') | ||
.pipe(replace(/~styles/g, function () { | ||
return path.relative(this.file.dirname, './dist/widget-library/styles').replace(/\\/g, '/') | ||
})) | ||
.pipe(dest('./dist/widget-library/')) | ||
}, | ||
async function packLibrary() { return execSync("npm pack ./widget-library", { cwd: './dist', stdio: 'inherit' }) } | ||
) | ||
|
||
const bundle = series( | ||
async function webpackBuild() { return execSync("npx webpack", {stdio: 'inherit'}) }, | ||
function copyCumulocityJson() { return fs.copy('./cumulocity.json', './dist/widget/cumulocity.json')}, | ||
function createZip() { | ||
return src('./dist/widget/**/*') | ||
// Filter out the webpackRuntime chunk, we only need the widget code chunks | ||
.pipe(filter(file => !/^[a-f0-9]{20}\.js(\.map)?$/.test(file.relative))) | ||
.pipe(zip('widget.zip')) | ||
.pipe(dest('dist/')) | ||
} | ||
) | ||
|
||
exports.clean = clean; | ||
exports.build = compile; | ||
exports.bundle = bundle; | ||
exports.default = series(clean, compile, bundle, async function success() { | ||
console.log("Build Finished Successfully!"); | ||
console.log("Runtime Widget Output (Install in the browser): dist/widget.zip"); | ||
const pkgJson = require('./dist/widget-library/package.json'); | ||
console.log(`Widget Angular Library (Install with: "npm i <filename.tgz>"): dist/${pkgJson.name}-${pkgJson.version}.tgz`); | ||
}); |
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,15 @@ | ||
{ | ||
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json", | ||
"assets": [ | ||
"styles/**/*" | ||
], | ||
"lib": { | ||
"entryFile": "../projects/gp-event-chart/src/public-api.ts", | ||
"umdModuleIds": { | ||
"@c8y/ngx-components": "@c8y/ngx-components" | ||
}, | ||
"flatModuleFile": "custom-widget" | ||
}, | ||
"whitelistedNonPeerDependencies": ["."], | ||
"dest": "dist/widget-library" | ||
} |
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,11 @@ | ||
{ | ||
"name": "event-chart-runtime-widget", | ||
"interleave": { | ||
"dist\\bundle-src\\custom-widget.js": "event-chart-runtime-widget-CustomWidget", | ||
"dist/bundle-src/custom-widget.js": "event-chart-runtime-widget-CustomWidget" | ||
}, | ||
"version": "1.0.0", | ||
"description": "Runtime package.json for library widget (written by Software AG Global Presales)", | ||
"author": "Darpankumar Lalani - Software AG, Global Presales", | ||
"license": "Apache 2.0" | ||
} |
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 @@ | ||
@import '~@angular/material/prebuilt-themes/indigo-pink.css'; | ||
|
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,64 @@ | ||
const URLImportPlugin = require("webpack-external-import/webpack"); | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
mode: 'production', | ||
devtool: 'source-map', | ||
entry: { | ||
[require('./cumulocity.json').contextPath]: './dist/bundle-src/custom-widget.js' | ||
}, | ||
resolve: { | ||
alias: { | ||
"~styles": path.resolve(__dirname, 'styles') | ||
} | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
use: ["source-map-loader"], | ||
enforce: "pre" | ||
},{ | ||
test: /\.css$/, | ||
use: ['style-loader', 'css-loader'] | ||
},{ | ||
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i, | ||
loader: 'url-loader', | ||
options: { | ||
limit: 8192, | ||
publicPath: `/apps/${require('./cumulocity').contextPath}/` | ||
}, | ||
} | ||
] | ||
}, | ||
optimization: { | ||
runtimeChunk: { | ||
name: "webpackRuntime" | ||
} | ||
}, | ||
plugins: [ | ||
new URLImportPlugin ({ | ||
manifestName: require('./cumulocity').contextPath, | ||
fileName: "importManifest.js", | ||
basePath: '', | ||
publicPath: `/apps/${require('./cumulocity').contextPath}/`, | ||
useExternals: { | ||
"@angular/animations": "AngularAnimations", | ||
"@angular/common": "AngularCommon", | ||
"@angular/common/http": "AngularCommonHttp", | ||
"@angular/core": "AngularCore", | ||
"@angular/forms": "AngularForms", | ||
"@angular/http": "AngularHttp", | ||
"@angular/platform-browser": "AngularPlatformBrowser", | ||
"@angular/platform-browser/animations": "AngularPlatformBrowserAnimations", | ||
"@angular/router": "AngularRouter", | ||
"@c8y/client": "C8yClient", | ||
"@c8y/ngx-components": "C8yNgxComponents" | ||
}, | ||
}) | ||
], | ||
output: { | ||
filename: '[contenthash].js', | ||
path: path.resolve(__dirname, 'dist/widget') | ||
}, | ||
}; |