Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/PULL_REQUEST_TEMPATE.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
## Description

<!-- Talk about the great work you've done! -->

### What's included?

<!-- List features included in this PR -->

- One
- Two
- Three

#### Test Steps

<!-- Add instructions on how to test your changes -->

- [ ] `npm ci`
- [ ] In `proxy.conf.js` file, change serverUrl to `https://appcenter.ux.ac.uda.io`
- [ ] `npm run serve`
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function(config) {
module.exports = function (config) {
config.set({
basePath: '.',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"test": "ng test ui-platform --code-coverage --source-map=false --watch=false",
"coveralls": "cat ./coverage/lcov.info | node ./node_modules/coveralls/bin/coveralls.js",
"build:lib": "bash scripts/build-release && gulp version-placeholder",
"test:schematics": "tsc -p src/lib/schematics/tsconfig.spec.json && jasmine src/lib/schematics/**/*.spec.js",
"release:start": "bash scripts/start-release",
"release:finish": "bash scripts/finish-release",
"generate:changelog": "./node_modules/.bin/conventional-changelog -i docs/CHANGELOG.md -s -p angular",
Expand Down
6 changes: 3 additions & 3 deletions protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ exports.config = {
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {},
print: function () {},
},
useAllAngular2AppRoots: true,
beforeLaunch: function() {
beforeLaunch: function () {
require('ts-node').register({
project: 'e2e',
});
},
onPrepare: function() {
onPrepare: function () {
jasmine.getEnv().addReporter(new SpecReporter());
},
};
2 changes: 1 addition & 1 deletion scripts/bump-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var knownOptions = {

var options = minimist(process.argv.slice(2), knownOptions);

gulp.task('bump-version', function() {
gulp.task('bump-version', function () {
if (!options.ver) {
throw '--ver is required';
}
Expand Down
25 changes: 25 additions & 0 deletions scripts/schematics/update-schematics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Run test and linter
npm run test:schematics
npm run tslint

# Link project
cd ../../src/lib
npm link

# Create Angular base project
cd /tmp
rm -rf testxyz
ng new testxyz
cd testxyz
ng add @angular/material @angular-devkit/schematics @angular/cdk
ng add @covalent/core

# Run covalent schematics
cd testxyz
git add .; git commit -m 'fix(update): commit updated';
npm link @td-vantage/ui-platform
ng update @td-vantage/ui-platform --migrate-only --from=0.0.0 --to=3.0.1

# Check generated files
git status
npm i
2 changes: 1 addition & 1 deletion scripts/version-placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var gulp = require('gulp');
const buildConfig = require('../build.conf');
const packageJson = require('../package.json');

gulp.task('version-placeholder', function(cb) {
gulp.task('version-placeholder', function (cb) {
replaceVersionPlaceholders(buildConfig.deployed, packageJson.version);
cb();
});
Expand Down
4 changes: 2 additions & 2 deletions src/lib/auth/config/vantageLoginProxyConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ function VantageLoginProxyConfig({ serverUrl, localUrl, localProto }) {
return {
'/start-login': {
target: serverUrl,
bypass: function(req, res, proxyOptions) {
bypass: function (req, res, proxyOptions) {
req.headers['X-Orig-Host'] = localUrl;
req.headers['X-Orig-Proto'] = localProto;
},
pathRewrite: function(path) {
pathRewrite: function (path) {
return path.replace(/^(\/start-login)/, '') || '/';
},
secure: false,
Expand Down
5 changes: 5 additions & 0 deletions src/lib/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
},
"license": "MIT",
"author": "Teradata UI Team",
"ng-update": {
"migrations": "./schematics/migration.json"
},
"peerDependencies": {
"@angular/common": "^0.0.0-NG",
"@angular/core": "^0.0.0-NG",
Expand Down
4 changes: 4 additions & 0 deletions src/lib/schematics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Outputs
**/*.js
**/*.js.map
**/*.d.ts
9 changes: 9 additions & 0 deletions src/lib/schematics/migration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"schematics": {
"covalent-migration-01": {
"description": "Upgrade to latest version",
"version": "3.0.1",
"factory": "./update/index#updateDependencies"
}
}
}
23 changes: 23 additions & 0 deletions src/lib/schematics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"baseUrl": ".",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"outDir": "../../../../deploy/ui-platform/schematics",
"lib": ["es2018", "dom"],
"moduleResolution": "node",
"sourceMap": true,
"target": "es6",
"typeRoots": ["./../../../../node_modules/@types"],
"noUnusedParameters": false,
"noUnusedLocals": false,
"allowUnreachableCode": false,
"pretty": true,
"importHelpers": true
},
"include": ["**/*"],
"exclude": ["**/*.spec.ts", "**/files/**/*"]
}
12 changes: 12 additions & 0 deletions src/lib/schematics/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": "./update",
"lib": ["es6", "dom"],
"module": "commonjs",
"types": ["jasmine", "hammerjs", "node"]
},
"include": ["**/*", "**/*.spec.ts"],
"exclude": ["*/files/**/*", "*/files/**/**/*"]
}
56 changes: 56 additions & 0 deletions src/lib/schematics/update/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Tree } from '@angular-devkit/schematics';
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import * as path from 'path';

import { Schema as WorkspaceOptions } from '@schematics/angular/workspace/schema';
import { Schema as ApplicationOptions } from '@schematics/angular/application/schema';
import chalk from 'chalk';

const green: any = chalk.green;
const yellow: any = chalk.yellow;

const migrationPath: string = require.resolve('../migration.json');
const packagePath: string = '/package.json';

function setup(): UnitTestTree {
const tree: UnitTestTree = Tree.empty() as UnitTestTree;
tree.create(
packagePath,
`{
"dependencies": {
"@covalent/core": "1.0.0"
}
}`,
);

return tree;
}
describe('ng-update schematic', () => {
const testRunner: SchematicTestRunner = new SchematicTestRunner('rocket', migrationPath);
let appTree: UnitTestTree;

beforeEach(async () => {
appTree = setup();
});

it('should print console messages', async () => {
// tslint:disable-next-line: no-console
console.log = jasmine.createSpy('log');
const tree: any = testRunner.runSchematic('covalent-migration-01', {}, appTree);
const pkg: any = JSON.parse(tree.readContent(packagePath));
expect(pkg.dependencies['@covalent/core']).toBe(`latest`);
// tslint:disable-next-line: no-console
expect(console.log).toHaveBeenCalledWith();
// tslint:disable-next-line
expect(console.log).toHaveBeenCalledWith(green(' ✓ Updated Covalent to latest'));
// tslint:disable-next-line
expect(console.log).toHaveBeenCalledWith();
// tslint:disable-next-line
expect(console.log).toHaveBeenCalledWith(
yellow(
' ⚠ Breaking changes are not applied automatically! Please refer the docs' +
'(https://github.com/Teradata/covalent/wiki) and fix the issues manually',
),
);
});
});
65 changes: 65 additions & 0 deletions src/lib/schematics/update/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Rule, SchematicContext, Tree, SchematicsException } from '@angular-devkit/schematics';
import chalk from 'chalk';
import { TargetVersion } from './target-version';

const green: any = chalk.green;
const yellow: any = chalk.yellow;

export interface IPackage {
dependencies?: object;
}

export function updateDependencies(): Rule {
return (tree: Tree, context: SchematicContext) => {
context.logger.info('Running covalent update schematic ...');
const pkgPath: string = '/package.json';
const buffer: Buffer = tree.read(pkgPath);
if (buffer === undefined) {
throw new SchematicsException('Could not read package.json');
}
const content: string = buffer.toString();
const pkg: IPackage = JSON.parse(content);

if (pkg === null || typeof pkg !== 'object' || Array.isArray(pkg)) {
throw new SchematicsException('Error reading package.json');
}

if (!pkg.dependencies) {
pkg.dependencies = {};
}

const packagesUpdated: boolean = updateCovalentPackage(pkg, tree, pkgPath);
if (packagesUpdated) {
onMigrationComplete();
}

return tree;
};

function updateCovalentPackage(pkg: IPackage, tree: Tree, pkgPath: string): boolean {
let isCovalentUpdated: boolean = false;
if (pkg.dependencies !== {} && Object.keys(pkg.dependencies) && Object.keys(pkg.dependencies).length !== 0) {
Object.keys(pkg.dependencies).forEach((key: string) => {
if (key.includes('@covalent')) {
pkg.dependencies[key] = TargetVersion.VERSION;
tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2));
isCovalentUpdated = true;
}
});
}
return isCovalentUpdated;
}

function onMigrationComplete(): void {
// tslint:disable: no-console
console.log();
console.log(green(` ✓ Updated Covalent to ${TargetVersion.VERSION}`));
console.log();
console.log(
yellow(
' ⚠ Breaking changes are not applied automatically! Please refer the docs' +
'(https://github.com/Teradata/covalent/wiki) and fix the issues manually',
),
);
}
}
3 changes: 3 additions & 0 deletions src/lib/schematics/update/target-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum TargetVersion {
VERSION = 'latest',
}