Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
fix: remove suffix (#20)
Browse files Browse the repository at this point in the history
add new test scenarios
  • Loading branch information
juanpicado authored Dec 26, 2019
1 parent d7d0c02 commit 28df490
Show file tree
Hide file tree
Showing 6 changed files with 1,667 additions and 95 deletions.
4 changes: 2 additions & 2 deletions generators/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class VerdaccioPluginGenerator extends Generator {
name: "keywords",
message: "Key your keywords (comma to split)",
filter: function(keywords) {
return _.uniq(_.words(keywords).concat(["verdaccio-plugin"]));
return _.uniq(_.words(keywords).concat(["verdaccio-"]));
}
}
];
Expand All @@ -105,7 +105,7 @@ export default class VerdaccioPluginGenerator extends Generator {
}

// @ts-ignore
this.projectName = `verdaccio-plugin-${pluginType}-${name}`;
this.projectName = `verdaccio-${pluginType}-${name}`;

// @ts-ignore
this.destinationPathName = resolve(this.projectName);
Expand Down
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@octokit/rest": "^16.35.2",
"@types/chalk": "^2.2.0",
"@types/express": "^4.17.2",
"@types/jest": "^24.0.21",
"@types/lodash": "^4.14.149",
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.7",
Expand All @@ -51,12 +50,6 @@
"yeoman-assert": "^3.0.0",
"yeoman-test": "^2.0.0"
},
"eslintConfig": {
"extends": "xo-space",
"env": {
"mocha": true
}
},
"repository": {
"type": "git",
"url": "git://github.com/verdaccio/generator-verdaccio-plugin"
Expand All @@ -65,7 +58,7 @@
"release": "standard-version -a -s",
"compile": "tsc",
"build": "yarn compile && yarn gulp build",
"test": "mocha test/app.test.js",
"test": "mocha test/*.test.js",
"lint": " eslint . --ext .js,.ts"
},
"license": "MIT"
Expand Down
56 changes: 0 additions & 56 deletions test/app.test.js

This file was deleted.

13 changes: 13 additions & 0 deletions test/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const defaultConfigFiles = [
'.babelrc',
'jest.config.js',
'.editorconfig',
'.gitignore',
'.travis.yml',
'package.json',
'README.md',
'.eslintrc',
'.npmignore'
];

module.exports = defaultConfigFiles;
183 changes: 183 additions & 0 deletions test/generator-template.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
const path = require('path');
const os = require('os');
const fs = require('fs');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const constants = require('./constants');

describe('template generator', function() {
const name = 'test';
const description = 'An amazing verdaccio plugin';
const githubUsername = 'testing';
const authorName = 'test';
const authorEmail = 'test';
const keywords = ['verdaccio, plugin, typescript'];
const license = 'MIT';
const repository = 'verdaccio/generator-test';
const getBuildAsset = (tempRoot, pluginType, item) => {
const prefixPath = path.join(tempRoot, `/verdaccio-${pluginType}-${name}`);
return `${prefixPath}/${item}`;
}

describe('generate app', function() {
const tempRoot = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), 'generator-app'));

describe('typescript', function() {
const lang = 'typescript';

it('should check storage files', function(done) {
pluginType = 'storage';
helpers.run(path.join(__dirname, '../generators/app')).inDir(tempRoot).withPrompts({
name,
lang,
pluginType,
description,
githubUsername,
authorName,
authorEmail,
keywords,
license,
repository
}).then(function() {
assert.file([
...constants.map(item => getBuildAsset(tempRoot, pluginType, item)),
getBuildAsset(tempRoot, pluginType, '/index.ts'),
getBuildAsset(tempRoot, pluginType, '/types/index.ts'),
getBuildAsset(tempRoot, pluginType, '/tsconfig.json'),
getBuildAsset(tempRoot, pluginType, '/src/index.ts'),
getBuildAsset(tempRoot, pluginType, '/src/plugin.ts'),
getBuildAsset(tempRoot, pluginType, '/src/PackageStorage.ts'),
])
done();
});
});

it('should check auth files', function(done) {
pluginType = 'auth';
helpers.run(path.join(__dirname, '../generators/app')).inDir(tempRoot).withPrompts({
name,
lang,
pluginType,
description,
githubUsername,
authorName,
authorEmail,
keywords,
license,
repository
}).then(function() {
assert.file([
...constants.map(item => getBuildAsset(tempRoot, pluginType, item)),
getBuildAsset(tempRoot, pluginType, '/src/index.ts'),
getBuildAsset(tempRoot, pluginType, '/index.ts'),
getBuildAsset(tempRoot, pluginType, '/types/index.ts'),
getBuildAsset(tempRoot, pluginType, '/tsconfig.json'),
])
done();
});
});

it('should check middleware files', function(done) {
pluginType = 'middleware';
helpers.run(path.join(__dirname, '../generators/app')).inDir(tempRoot).withPrompts({
name,
lang,
pluginType,
description,
githubUsername,
authorName,
authorEmail,
keywords,
license,
repository
}).then(function() {
assert.file([
...constants.map(item => getBuildAsset(tempRoot, pluginType, item)),
getBuildAsset(tempRoot, pluginType, '/src/index.ts'),
getBuildAsset(tempRoot, pluginType, '/index.ts'),
getBuildAsset(tempRoot, pluginType, '/types/index.ts'),
getBuildAsset(tempRoot, pluginType, '/tsconfig.json'),
])
done();
});
});
});

describe('javascript', function() {
const lang = 'javascript';
let pluginType;

it('should check storage files', function(done) {
pluginType = 'storage';
helpers.run(path.join(__dirname, '../generators/app')).inDir(tempRoot).withPrompts({
name,
lang,
pluginType,
description,
githubUsername,
authorName,
authorEmail,
keywords,
license,
repository
}).then(function() {
assert.file([
...constants.map(item => getBuildAsset(tempRoot, pluginType, item)),
getBuildAsset(tempRoot, pluginType, '/src/index.js'),
getBuildAsset(tempRoot, pluginType, '/index.js'),
getBuildAsset(tempRoot, pluginType, '/src/plugin.js'),
getBuildAsset(tempRoot, pluginType, '/src/PackageStorage.js'),
])
done();
});
});

it('should check auth files', function(done) {
pluginType = 'auth';
helpers.run(path.join(__dirname, '../generators/app')).inDir(tempRoot).withPrompts({
name,
lang,
pluginType,
description,
githubUsername,
authorName,
authorEmail,
keywords,
license,
repository
}).then(function() {
assert.file([
...constants.map(item => getBuildAsset(tempRoot, pluginType, item)),
getBuildAsset(tempRoot, pluginType, '/src/index.js'),
getBuildAsset(tempRoot, pluginType, '/index.js'),
])
done();
});
});


it('should check middleware files', function(done) {
pluginType = 'middleware';
helpers.run(path.join(__dirname, '../generators/app')).inDir(tempRoot).withPrompts({
name,
lang,
pluginType,
description,
githubUsername,
authorName,
authorEmail,
keywords,
license,
repository
}).then(function() {
assert.file([
...constants.map(item => getBuildAsset(tempRoot, pluginType, item)),
getBuildAsset(tempRoot, pluginType, '/src/index.js'),
getBuildAsset(tempRoot, pluginType, '/index.js'),
])
done();
});
});
});
});
});
Loading

0 comments on commit 28df490

Please sign in to comment.