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

fix(cli): remove copyright header from generated app #991

Merged
merged 2 commits into from
Feb 14, 2018
Merged
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
11 changes: 0 additions & 11 deletions packages/cli/generators/app/templates/index.js

This file was deleted.

6 changes: 6 additions & 0 deletions packages/cli/generators/app/templates/index.js.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const application = (module.exports = require('./dist'));

if (require.main === module) {
// Run the application
application.main();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: @loopback/cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ApplicationConfig} from '@loopback/core';
import {RestApplication, RestServer} from '@loopback/rest';
import {PingController} from './controllers/ping.controller';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: @loopback/cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {ServerRequest} from '@loopback/rest';
import {get} from '@loopback/openapi-v2';
import {inject} from '@loopback/context';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: @loopback/cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {<%= project.applicationName %>} from './application';
import {ApplicationConfig} from '@loopback/core';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: @loopback/cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Context, inject} from '@loopback/context';
import {
FindRoute,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Copyright IBM Corp. 2017,2018. All Rights Reserved.
// Node module: @loopback/cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {createClientForHandler, supertest} from '@loopback/testlab';
import {RestServer} from '@loopback/rest';
import {<%= project.applicationName %>} from '../';
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/generators/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ module.exports = class ControllerGenerator extends ArtifactGenerator {
debug(`Artifact filename set to: ${this.artifactInfo.filename}`);
}
// renames the file
let template = 'controller-template.ts';
let template = 'controller-template.ts.template';
switch (this.artifactInfo.controllerType) {
case ControllerGenerator.REST:
template = 'controller-rest-template.ts';
template = 'controller-rest-template.ts.template';
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
// Copyright IBM Corp. 2018. All Rights Reserved.
// Node module: @loopback/cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

import {Filter, Where} from '@loopback/repository';
import {post, param, get, put, patch, del} from '@loopback/openapi-v2';
import {inject} from '@loopback/context';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Uncomment these imports to begin using these cool features!

// import {inject} from @loopback/context;


export class <%= name %>Controller {
constructor() {}
}
6 changes: 0 additions & 6 deletions packages/cli/generators/extension/templates/index.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist';
6 changes: 0 additions & 6 deletions packages/cli/generators/extension/templates/index.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist');
14 changes: 0 additions & 14 deletions packages/cli/generators/extension/templates/src/component.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {Component, ProviderMap} from '@loopback/core';

export class <%= project.componentName %> implements Component {
constructor() {}

providers?: ProviderMap = {
};

}
6 changes: 0 additions & 6 deletions packages/cli/generators/extension/templates/src/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './component';
11 changes: 0 additions & 11 deletions packages/cli/generators/project/templates/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src';
21 changes: 21 additions & 0 deletions packages/cli/lib/project-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// License text available at https://opensource.org/licenses/MIT

'use strict';
const rename = require('gulp-rename');
const BaseGenerator = require('./base-generator');
const utils = require('./utils');

Expand Down Expand Up @@ -55,6 +56,26 @@ module.exports = class ProjectGenerator extends BaseGenerator {
const isValid = utils.validate(this.args[0]);
if (typeof isValid === 'string') throw new Error(isValid);
}

this.setupRenameTransformer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line of code needed? I thought functions defined in Yeoman index files get called in sequential order they're defined in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. If I comment it out and run CLI, the transformer is not registered ...

}

/**
* Registers a Transform Stream with Yeoman. Removes `.template` extension
* from files that have it during project generation.
*/
setupRenameTransformer() {
this.registerTransformStream(
rename(function(file) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a function that can do this for us without having to import another package? I guess it's not a huge deal regardless though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can write a function ourselves ... but I didn't want to re-invent the wheel. (And it requires dealing with streams ... )

// extname already contains a leading '.'
const fileName = `${file.basename}${file.extname}`;
const result = fileName.match(/(.+)(.ts|.js)\.template$/);
if (result) {
file.extname = result[2];
file.basename = result[1];
}
})
);
}

setOptions() {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"chalk": "^2.3.0",
"change-case": "^3.0.1",
"debug": "^3.1.0",
"gulp-rename": "^1.2.2",
"gunzip-maybe": "^1.4.1",
"lodash": "^4.17.4",
"minimist": "^1.2.0",
Expand Down