Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: postinstall message #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
6 changes: 3 additions & 3 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@angular-devkit/core": "^12.0.1",
"@angular-devkit/schematics": "^12.0.1",
"@schematics/angular": "^12.0.1",
"chalk": "^4.1.2",
"typescript": "~4.1.2"
},
"devDependencies": {
Expand Down
22 changes: 22 additions & 0 deletions src/schematics/nightwatch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import {
} from './utility/util';
import { addPackageJsonDependency } from './utility/dependencies';
import getFramework from './utility/framework';
import { cyanBright, yellowBright } from 'chalk';

let globalObject: any = {};

// You don't have to export the function as default. You can also have more than one rule factory
// per file.
Expand All @@ -37,6 +40,7 @@ export default function (_options: SchematicsOptions): Rule {
addNightwatchConfigFile(),
addNightwatchTestsScriptToPackageJson(_options),
!_options.noBuilder ? modifyAngularJson(_options) : noop(),
postInstallMessage(_options),
])(tree, _context);
};
}
Expand Down Expand Up @@ -69,6 +73,22 @@ export function addNightwatchTestsScriptToPackageJson(options: SchematicsOptions
};
}

function postInstallMessage(options: SchematicsOptions) {
return (_tree: Tree, context: SchematicContext) => {
let message = '\n';
if (options.removeProtractor && globalObject.delete_e2e) {
message += cyanBright(
`We had moved the 'e2e' folder to the new location i.e. 'protractor'.\n`
);
}
message +=
cyanBright(
`Sample Nightwatch tests can be found under the 'nightwatch' folder. \nTo get started with Nightwatch, please visit: `
) + yellowBright(`https://nightwatchjs.org/gettingstarted/configuration/\n`);
context.logger.info(message);
};
}

function modifyAngularJson(options: SchematicsOptions): Rule {
return (tree: Tree, context: SchematicContext) => {
if (tree.exists('./angular.json')) {
Expand Down Expand Up @@ -230,6 +250,8 @@ function removeFiles(): Rule {
function deleteDirectory(tree: Tree, path: string): void {
try {
if (tree.getDir(path).subfiles.length > 0 || tree.getDir(path).subdirs.length > 0) {
globalObject.delete_e2e = true;

tree.rename('e2e', `protractor/${path}`);
} else {
console.warn(`⚠️ Skipping deletion: ${path} doesn't exist`);
Expand Down