Skip to content

Commit

Permalink
Merge pull request #15 from wizsolucoes/release/update-env
Browse files Browse the repository at this point in the history
feat: pipeline b2c login
  • Loading branch information
raulmelo authored Mar 8, 2024
2 parents 0d4ca01 + 1c76a7c commit 99fbc93
Show file tree
Hide file tree
Showing 9 changed files with 14,466 additions and 245 deletions.
499 changes: 307 additions & 192 deletions angular.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion application-webcomponents/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wizco/schematics-webcomponents",
"version": "17.1.8",
"version": "17.1.9",
"description": "Wizpro angular schematics for module MFE",
"scripts": {
"build": "tsc -p tsconfig.json",
Expand Down
5 changes: 5 additions & 0 deletions application-webcomponents/src/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"factory": "./template-mfe-final-change",
"schema": "./template-mfe-final-change/schema.json",
"description": "Modificador Webpack"
},
"env-b2c": {
"factory": "./env-b2c",
"schema": "./env-b2c/schema.json",
"description": "Inserir variáveis de ambiente"
}
}
}
74 changes: 74 additions & 0 deletions application-webcomponents/src/env-b2c/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {
chain,
Rule,
SchematicContext,
SchematicsException,
Tree,
} from '@angular-devkit/schematics';

function addPipelineDefault(): Rule {
return (tree: Tree, context: SchematicContext) => {

// eslint-disable-next-line no-debugger
debugger
context.logger.info('Adicionando o pipeline default...');
const angularJson = tree.read(`angular.json`)!.toString('utf-8');

if (!angularJson) {
throw new SchematicsException('No package.json file found');
}

const packageJsonObject = JSON.parse(angularJson.toString());
const projects = packageJsonObject.projects;

for (const project in projects) {
if (
projects[project].projectType === 'application' &&
projects[project].architect &&
projects[project].architect.build &&
projects[project].architect.build.configurations &&
projects[project].architect.build.configurations.sandbox
) {
// script para criar o arquivo environment.b2c.ts
const sandboxConfig = projects[project].architect.build.configurations.sandbox;
const local = sandboxConfig['fileReplacements'][0]['with'];
const localSandbox = tree.read(local)!.toString('utf-8');
tree.create(local.replace('environment.sandbox.ts', 'environment.b2c.ts'), localSandbox);
// script para adicionar no angular.json
projects[project].architect.build.configurations['b2c'] = {
...sandboxConfig,
fileReplacements: [
{
replace: sandboxConfig['fileReplacements'][0]['replace'],
with: local.replace('environment.sandbox.ts', 'environment.b2c.ts' ),
},
],
};
}
}

const newAngular = {
...packageJsonObject,
projects: projects,
};

tree.overwrite(`angular.json`, JSON.stringify(newAngular, null, 2));
return tree
};
}

export default function (): Rule {
return () => {
return chain([
addPipelineDefault()
]);
};
}
70 changes: 70 additions & 0 deletions application-webcomponents/src/env-b2c/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "env-b2c",
"title": "B2C Pipe",
"type": "object",
"description": "Generates a new basic application definition in the \"projects\" subfolder of the workspace.",
"additionalProperties": false,
"properties": {
"inlineStyle": {
"description": "Include styles inline in the root component.ts file. Only CSS styles can be included inline. Default is false, meaning that an external styles file is created and referenced in the root component.ts file.",
"type": "boolean",
"alias": "s",
"x-user-analytics": 9
},
"inlineTemplate": {
"description": "Include template inline in the root component.ts file. Default is false, meaning that an external template file is created and referenced in the root component.ts file. ",
"type": "boolean",
"alias": "t",
"x-user-analytics": 10
},
"viewEncapsulation": {
"description": "The view encapsulation strategy to use in the new application.",
"enum": ["Emulated", "None", "ShadowDom"],
"type": "string",
"x-user-analytics": 11
},
"style": {
"description": "The file extension or preprocessor to use for style files.",
"type": "string",
"default": "scss",
"enum": ["css", "scss", "sass", "less"]
},
"skipTests": {
"description": "Do not create \"spec.ts\" test files for the application.",
"type": "boolean",
"default": false,
"alias": "S",
"x-user-analytics": 12
},
"skipPackageJson": {
"type": "boolean",
"default": false,
"description": "Do not add dependencies to the \"package.json\" file."
},
"minimal": {
"description": "Create a bare-bones project without any testing frameworks. (Use for learning purposes only.)",
"type": "boolean",
"default": false,
"x-user-analytics": 14
},
"skipInstall": {
"description": "Skip installing dependency packages.",
"type": "boolean",
"default": false
},
"strict": {
"description": "Creates an application with stricter bundle budgets settings.",
"type": "boolean",
"default": true,
"x-user-analytics": 7
},
"routing": {
"description": "Generate a routing module.",
"type": "boolean",
"default": true,
"alias": "r",
"x-user-analytics": 8
}
}
}
6 changes: 3 additions & 3 deletions application-webcomponents/src/template-webcomponents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ function addScripts(option: OptionsDefaultModule): Rule {
const scripts = packageJsonObject.scripts;

scripts['start:module'] = `ng serve --project ${projectName}`;
scripts['build:module'] = `ng build --project ${projectName} --output-hashing none --aot --build-optimizer`;
scripts['build:module:staging'] = `ng build --configuration staging --project ${projectName} --output-hashing none --aot --build-optimizer`;
scripts['build:module:sandbox'] = `ng build --configuration sandbox --project ${projectName} --output-hashing none --aot --build-optimizer`;
scripts['build:module'] = `ng build --project ${projectName} --output-hashing none --aot`;
scripts['build:module:staging'] = `ng build --configuration staging --project ${projectName} --output-hashing none --aot`;
scripts['build:module:sandbox'] = `ng build --configuration sandbox --project ${projectName} --output-hashing none --aot`;

tree.overwrite('package.json', JSON.stringify(packageJsonObject, null, 2));

Expand Down
Loading

0 comments on commit 99fbc93

Please sign in to comment.