Skip to content

Instantly share code, notes, and snippets.

View anfibiacreativa's full-sized avatar
🦆
Quack!

Natalia Venditto anfibiacreativa

🦆
Quack!
View GitHub Profile
@anfibiacreativa
anfibiacreativa / schema.json
Created February 14, 2019 10:22
Validation schema for angular schematics
{
"$schema": "http://json-schema.org/schema",
"id": "SchematicsGenerateFilesApp",
"title": "Application Options Schema for Angular projects feat Aliased SASS",
// the type of the schema object (obviously object!)
"type": "object",
// the properties of that object
"properties": {
// name, maps to an option you expect from the command line, flagged --name
"name": {
const {
GLOBAL_VENDOR_JS = '',
GLOBAL_COMPONENTS = '',
TENANT_COMPONENTS = '',
} = require('./project.paths.config');
// export alias for JS
module.exports = {
'global.vendors': GLOBAL_VENDOR_JS,
'global.components': GLOBAL_COMPONENTS,
const path = require('path');
// this comes from maven env
const TENANT = process.env.NPM_FRONTEND_MODULE_BASE_DIR;
const TENANT_NAME = TENANT.split('/').reverse()[2];
const TENANT_COMPONENTS = TENANT.substr(0, TENANT.lastIndexOf('/'));
const PROJECT_ID = 'project-id';
console.log(`############## FRONTEND BUILD ##############`);
console.log(`############## STARTING BUILD FOR TENANT: ${TENANT_NAME} ##############`);
const glob = require('fast-glob');
const path = require('path');
function collectEntries(config, extension) {
// we have called all our js and scss files like this `component-name.entry.js` and `component-name.entry.scss`
const pattern = `**/*.entry.${extension}`;
// if you take a look at project structure we defined
// and the project.paths.conig.js file above, you will see the path to iterate in this case
// is the `tenants/tenantN/components/package/src/frontend/components`
// since when globbing cwd will be the directory where this file is at
// ...
"paths": {
"conf": "./config",
"tasks": "./tasks"
},
"scripts": {
"build": "npm-run-all --parallel build:*",
// you cannot write comments in package.json (or any json, so don't do this! ;)
// but to explain this, $npm_package_paths_configs refers to what you have as value in the
// paths property up there
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Our Multitenant Project: Build Reactor POM</name>
<groupId>[SOME-ID]</groupId>
<artifactId>[SOME-OTHER-ID]</artifactId>
<version>[SOME-VERSION]</version>
<packaging>pom</packaging>
<configuration>
<workingDirectory>${frontend.build.directory}</workingDirectory>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>Tenant One Package</name>
<artifactId>[SOME-ID]</artifactId>
<packaging>content-package</packaging>
<parent>
<configuration>
<environmentVariables>
<NPM_FRONTEND_MODULE_BASE_DIR>${basedir}</NPM_FRONTEND_MODULE_BASE_DIR>
</environmentVariables>
</configuration>
$ cd ~/frontend
$ NPM_FRONTEND_MODULE_BASE_DIR=tenants/tenant/components/package npm run build