Skip to content

Commit

Permalink
fix(cli): remove copyright header from generated app
Browse files Browse the repository at this point in the history
use `.template` extension for templates. Rename during project generation. Removes copyright headers from templates.

Fixes #944
  • Loading branch information
virkt25 committed Feb 13, 2018
1 parent f13f603 commit a766a5f
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 99 deletions.
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';
19 changes: 19 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,24 @@ module.exports = class ProjectGenerator extends BaseGenerator {
const isValid = utils.validate(this.args[0]);
if (typeof isValid === 'string') throw new Error(isValid);
}

this.setupRenameTransformer();
}

/**
* Registers a Transform Stream with Yeoman. Removes `.template` extension
* from files that have it during project generation.
*/
setupRenameTransformer() {
this.registerTransformStream(
rename(function(file) {
if (file.extname === '.template') {
const split = file.basename.split('.');
file.extname = `.${split.pop()}`;
file.basename = split.join('.');
}
})
);
}

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

0 comments on commit a766a5f

Please sign in to comment.