plopjs / node-plop Goto Github PK
View Code? Open in Web Editor NEWprogrammatic plopping for fun and profit
Home Page: http://plopjs.com
programmatic plopping for fun and profit
Home Page: http://plopjs.com
Inquirer prompts allow the user to specify a filter
function on a question. Specifying a filter
works when a prompt is not bypassed. However, it is not executed when bypassing the prompt.
Expected behavior:
When bypassing prompts - if there is a filter
for that prompt then it should be executed.
e.g.
module.exports = plop => {
plop.setGenerator("container", {
description: "Generate React container component",
prompts: [
{
type: "input",
name: "name",
message: "Container name",
filter: answer => `${answer}Container`
}
],
actions: [
{
type: "add",
path: "src/containers/{{pascalCase name}}.js",
templateFile: "./container.hbs"
}
]
});
};
2.2.0
to 2.3.0
.This version is covered by your current version range and after updating it in your project the build failed.
ava is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
import-local@^3.0.2
which fixes issues with Lerna projects.t.context
to unknown
, in line with TypeScript's changes in their 3.5 release. 2fc7d56Thank you @MarchWorks, @yovasx2 and @bobthekingofegypt. We couldn't have done this without you!
We welcome new contributors. AVA is a friendly place to get started in open source. We have a great article on getting started contributing and a comprehensive contributing guide.
The new version differs by 10 commits.
1c81c4b
2.3.0
9e8d28f
Watcher: Only track test files has having exclusive tests if at least one test was selected
7dcb473
Update fake-tty for changes in Node.js 12.7.0
9baca8c
Enable V8 supported stage-3 syntax, as well as stage-4 syntax
7fb0546
Bump dependencies
ffa62ce
Consistent paths in watcher
b27cb8d
Print internal errors when precompiler setup or globbing fails
8628976
Print hooks and remaining tests as TAP comments
f01d05f
Ensure CLI receives file paths
2fc7d56
Change default Context type to unknown
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
If I have the following:
|- base
|- src
|- components
|- hello.js (template)
|- additional
|- src
|- helpers
|- hey.js (template)
Is there a way to end up with this?
|- base
|- src
|- components
|- hello.js
|- helpers
|- hey.js
I've tried chaining addMany
and it doesn't like it:
{
type: 'addMany',
templateFiles: `./base/**/*`,
globOptions: { dot: true },
base: './base/',
destination: './some-folder'
},
{
type: 'addMany',
templateFiles: `./additional/**/*`,
globOptions: { dot: true },
base: './base/',
destination: './some-folder'
}
I've tried a comma glob pattern in one addMany
and it doesn't like it:
{
type: 'addMany',
templateFiles: `./base/**/*, ./additional/**/*`,
globOptions: { dot: true },
base: './base/',
destination: src
}
Perhaps there is a globOptions
thing that I can't work out? Is this even possible, and am I approaching this correctly?
As @amwmedia suggest, Add pre-commit to run the tests in each commit or PR.
Several properties in the ActionType(s) hierarchy should be declared as property?
I think.
comparing: https://github.com/plopjs/node-plop/blob/master/index.d.ts#L65
to: https://github.com/plopjs/plop#your-first-plopfile
The problem occurs when you run $ npm run develop
for second time. I clone the project, I run npm run develop
and all is alright, but when I run it for a second time, the console is showing me a error:
loudRejection/api is deprecated. Use the currently-unhandled module instead.
module.js:327
throw err;
^
Error: Cannot find module '../lib/index.js'
I will try to figure out what is happening.
When dynamically generating an actions array using a plopfile
written in TypeScript, then TypeScript raises an error:
Type '({ componentName }: object) => { type: "add"; path: string; }[]' is not assignable to type 'ActionType<object>[] | CustomActionFunction<object>'.
Type '({ componentName }: object) => { type: "add"; path: string; }[]' is not assignable to type 'CustomActionFunction<object>'.
Type '{ type: "add"; path: string; }[]' is not assignable to type 'ActionType<object>[] | Promise<ActionType<object>[]>'.
Type '{ type: "add"; path: string; }[]' is not assignable to type 'ActionType<object>[]'.
Type '{ type: "add"; path: string; }' is not assignable to type 'ActionType<object>'.
Type '{ type: "add"; path: string; }' is missing the following properties from type 'AppendActionConfig<object>': pattern, template, templateFile, force, and 2 more.ts(2322)
index.d.ts(129, 3): The expected type comes from property 'actions' which is declared here on type 'PlopGenerator'
import { NodePlopAPI } from 'plop';
export default (plop: NodePlopAPI) => {
plop.setGenerator('component', {
description: 'React component',
prompts: [
{
type: 'input',
name: 'componentName',
message: "What's the name of your component?"
},
// ...
],
actions: ({ componentName }) => [
{
type: 'add',
path: `./${componentName}.js`,
// ...
}
]
});
}
Dynamic action arrays should be typed correctly.
Plop: 2.5.3
TypeScript: 3.7.3
The actual test structure using an index (test.ava.js
) works but is not ideal as we discussed in here.
Just got a notification that the handlebars dependency of node-plop has a high-risk vulnerability:
If you have a directory, with say templates/{index.js,test.js}.hbs
- and run the action addMany
, could that potentially support an additional property to drop of a file extension?
as in:
module.exports = function(plop) {
plop.setGenerator('component', {
description: 'Generate a new component',
prompts: [
{
type: 'input',
name: 'name',
message: 'component name?',
},
],
actions() {
return [
{
type: 'addMany',
destination: 'lib/components/{{ pascalCase name }}.{{ ext }}',
base: 'templates/component/',
ext: 'without-hbs', // or 'as-is', or ext(incomingFile:string): string
templateFiles: 'templates/component/**/*',
},
];
},
});
};
Hello, I've been using the library and found a slight issue with the typing for generators.
There appears to be support for the prompt value of a generator config to be a function:
node-plop/src/generator-runner.js
Line 19 in 74f4e08
But this is not reflected in the typing:
prompts: inquirer.Question[];
Let me know if you'd like me to take a crack at this! Should be simple and very similar to the actions typing in that same interface:
actions: Actions | DynamicActionFunction;
Thanks!
Plop is a wonderful tool, so thank you for developing it 👍🏻
Would it be possible to add support for dynamic prompts defined by a function? Currently, plop expects the prompts to be defined by an object, but I need to prompt the user with different questions depending on the user's previous answers. I'm happy to submit a quick PR but wanted to run it by you first.
Here is a simplified example illustrating my use case:
// prompts.js
function promptForFileName(inquirer, answers = {}) {
const prompts = inquirer.prompt([{
type: 'input',
name: 'name',
message: 'What should be the name of your new file?'
}, {
type: 'confirm',
name: 'overrideContent',
message: 'Do you wanna override the default content?'
}]);
prompts.then((newAnswers) => {
Object.assign(newAnswers, answers);
});
return prompts;
}
function promptForContent(inquirer, answers = {}) {
const prompts = inquirer.prompt({
type: 'input',
name: 'content',
message: 'Content:'
});
prompts.then((newAnswers) => {
Object.assign(newAnswers, answers);
});
return prompts;
}
module.exports = function(inquirer) {
const basePrompt = promptForFileName(inquirer);
return basePrompt.then((answers) => {
if (answers.overrideContent) {
return promptForContent(inquirer, answers);
}
return basePrompt;
});
};
// plopfile.js
const prompts = require('./prompts');
module.exports = function (plop) {
plop.setGenerator('dynamic-actions', {
description: 'another test using an actions function',
prompts: prompts,
actions: function(data) {
if (!data.overrideContent) {
data.content = 'Default content';
}
return [
{
type: 'add',
path: `./${data.name}.txt`,
template: '{{ content }}'
}
];
}
});
};
When a binary file such as a image file is located within the templates folder and addMany
is used, it will throw a very cryptic error message as such:
[FAILED] addMany Lexical error on line 1. Unrecognized text.
☺ ☻ ►► h♦ &
^
A code example can be found here:
https://github.com/crutchcorn/generate-me/tree/14370feb32d05f913387929c7ac1359c52ed3b1a
By running node index.js "Test" n y
, you can see the behavior
Getting an error on these default function parameters, which isn't supported in node 4:
https://github.com/amwmedia/node-plop/blob/master/src/modules/node-plop.js#L8
function nodePlop(plopfilePath = '', plopCfg = {}) {
SyntaxError: Unexpected token =
I see that babel is set up to read the system node version, so you may need to run the build with your machine running node 4 before publishing, or change the engines field in package.json to >= 6
I am making a custom a action, here are the args:
{
answers: { domainName: 'admin' },
config: {
type: 'CreateDirectory',
path: 'src/domain/{domainName}/mutation',
force: false
}
}
I am trying to get src/domain/admin/mutation
I tried this:
import * as plopUtils from 'node-plop/lib/actions/_common-action-utils.js';
const dest = plopUtils.makeDestPath(answers, config, plop)
But still not resolved
/Users/Desktop/src/domain/{domainName}/mutation
It seems that when action.data
is a function, it receives no arguments.
node-plop/src/generator-runner.js
Lines 114 to 116 in decdd3f
I found the type definition confusing misleading:
Lines 171 to 176 in decdd3f
Should the data function receive the existing data from the prompts? This could be useful for file loading, etc...
I can make a pull request if this is welcome!
Not sure, that this is an issue, this is an OSS and I don't want to be pushy, but can you make a release? :) Please 😄
Last release was in November and right now using of plop
in TS is blocked by:
DynamicActionFunction
, which was added in Decemberv0.23.0...master list of comments with diff
Much thx for your job on this generator! 👍
A minor refactor in test.ava.js
to use ES6 import
instead of require. Also, regroup all the imports at the beginning of the document to improve the developer experience.
Hi,
I try to load te plopfile from global lib but, when I try to add some files the path where I want create is wrong
This is the file that run node-plop:
#!/usr/bin/env node
'use strict';
const nodePlop = require('node-plop');
const plop = nodePlop(__dirname + `/plopfile.js`);
async function createMs(){
let msGen = plop.getGenerator('ms');
try{
let data = await msGen.runPrompts();
let result = await msGen.runActions(data);
let changes = result.changes;
let fails = result.failures;
console.log(fails);
console.log(changes);
}catch(error){
console.log(error);
}
createMs();
I packing this function whit the plofile and then install npm i -g lib.tgz
then calling this using mg new ms
.
When try to write de proyect folder throws this error, because is trying to write in the path where plopfile is located no where comand is called
[ { type: 'addMany',
path: '',
error: 'EACCES: permission denied, mkdir \'/usr/lib/node_modules/ms-node-generator/my-microservice\'' } ]
[]
Currently pkg
helper is broken since plup uses wrong path to load package.json
:
https://github.com/amwmedia/node-plop/blob/master/src/modules/node-plop.js#L112
Basicly node-plop uses path before setPlopfilePath
is called, so instead of /foo/bar/package.json
it uses /foo/bar/plopfile.js/package.json
.
Solution:
+ try { pkgJson = require(path.join(path.dirname(getDestBasePath()), 'package.json')); }
But this is kinda "hack", the problem itself is that plopfilePath
contains both file path and directory path depending on time.
5.0.0
to 5.1.0
.This version is covered by your current version range and after updating it in your project the build failed.
del is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.
Enhancements:
Fixes:
Shoutout to @chrisblossom for doing most of the work on this release 🙌
The new version differs by 12 commits.
557c1fa
5.1.0
12c443d
Meta tweaks
01da91f
Allow non-glob patterns with backslash on Windows (#100)
9c72270
Add benchmarks (#101)
1299747
Use graceful-fs (#108)
f509a89
Update dependencies (#109)
ca05c65
Sort removed files (#102)
51662ac
Reverse order back for the returned paths (#99)
902b594
Meta tweaks
ffbf4c4
Fix the cwd
option (#96)
8efdbcd
Prevent race condition on macOS when deleting files (#95)
9e7550b
Add note about backward-slashes
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
A couple of the log messages from plop say "file does not exists". The word "exists" should be made singular.
Cannot read property 'toString' of undefined
My blog:
https://github.com/tychota/blog/tree/257dbb6b553a745c691e9eb4eb4602a0f191d55f
You can find the package.json and the plopfile
patch-package
--- a/node_modules/node-plop/lib/generator-runner.js
+++ b/node_modules/node-plop/lib/generator-runner.js
@@ -111,7 +111,7 @@ exports.default = function (plopfileApi, flags) {
// show the resolved value in the console
result => ({
type: cfg.type || 'function',
- path: _colors2.default.blue(result.toString())
+ path: _colors2.default.blue(result && result.toString())
}),
// a rejected promise is treated as a failure
function (err) {
used with patch-package fix the problem.
I will be super please to PR a better fix if you have an idea. I must understand why in this case result is undefined. And then fix so result of Add action so the root cause is fixed.
Would be kind if you can help me going in the right direction.
If I don't answser in github, you can ping me in twitter (@tychota) ! Github notifications is quite messy for me.
This is weird I'm making my generator based on plop and the addMany
action is copying the template folders and the files. Is better with an illustrated example:
This is my addMany action
{
type: 'addMany',
destination: `${basepath}/components/{{folder_name}}`,
templateFiles: 'templates/generator/smart/*'
},
where basepath
is:
const currentPath = process.cwd()
const basepath = path.resolve(currentPath, '../')
if I execute the ploplfile, the results is:
prueba2
is the folder_name
and then, plop copy the folders of the templateFiles into folder_name
, generator/smart/....
I really don't know what is happening here, is weird for me. Can anyone help me?
Inquirer gives a named object of 'answers' to each action.
Sometimes I want transformations of those in the templates. I currently use the handlebars helpers for this. I repeat them a lot.
I might be nice if the plop
object had those answers, and made them modifiable. This would allow actions like:
plop.setActionType('postProcessAnswers', (answers, config, plop) => {
plop.answers.someOther = someFunction(answers.firstAnswer);
});
This might also be a terrible idea :) Thanks!
I didn't try the tests until now and when I tried a get a bunch of SyntaxErrors related with new ES6 features.
Just a few changes to accommodate 100% ES6.
If I have a .gitignore
file that is in my templates folder, it is not copied into the directory I wish to place my newly generated template into. You can see a code example here:
https://github.com/crutchcorn/generate-me/tree/14370feb32d05f913387929c7ac1359c52ed3b1a
By running node index.js "Test" y n
and looking into src/server
, you can see the behavior
$ ng test
import * as nodePlop from 'node-plop';
describe('test', () => {
console.log(nodePlop)
});
WARNING in ./packages/cli/node_modules/node-plop/lib/node-plop.js
168:13-76 Critical dependency: the request of a dependency is an expression
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
WARNING in ./packages/cli/node_modules/node-plop/lib/node-plop.js
236:2-58 Critical dependency: the request of a dependency is an expression
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
WARNING in ./packages/cli/node_modules/handlebars/lib/index.js
require.extensions is not supported by webpack. Use a loader instead.
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js 19:18-39
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
WARNING in ./packages/cli/node_modules/handlebars/lib/index.js
require.extensions is not supported by webpack. Use a loader instead.
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js 19:18-39
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
WARNING in ./packages/cli/node_modules/handlebars/lib/index.js
require.extensions is not supported by webpack. Use a loader instead.
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js 19:18-39
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/external-editor/main/index.js
Module not found: Error: Can't resolve 'child_process' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/external-editor/main'
@ ./packages/cli/node_modules/external-editor/main/index.js 17:14-38 19:10-34
@ ./packages/cli/node_modules/inquirer/lib/prompts/editor.js
@ ./packages/cli/node_modules/inquirer/lib/inquirer.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/async/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/async'
@ ./packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/async/index.js 9:6-19
@ ./packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/index.js
@ ./packages/cli/node_modules/fast-glob/out/providers/reader-sync.js
@ ./packages/cli/node_modules/fast-glob/out/index.js
@ ./packages/cli/node_modules/fast-glob/index.js
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/stream/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/stream'
@ ./packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/stream/index.js 8:6-19
@ ./packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/index.js
@ ./packages/cli/node_modules/fast-glob/out/providers/reader-sync.js
@ ./packages/cli/node_modules/fast-glob/out/index.js
@ ./packages/cli/node_modules/fast-glob/index.js
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/sync/fs.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/sync'
@ ./packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/sync/fs.js 3:11-24
@ ./packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/sync/index.js
@ ./packages/cli/node_modules/@mrmlnc/readdir-enhanced/lib/index.js
@ ./packages/cli/node_modules/fast-glob/out/providers/reader-sync.js
@ ./packages/cli/node_modules/fast-glob/out/index.js
@ ./packages/cli/node_modules/fast-glob/index.js
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/@nodelib/fs.stat/out/adapters/fs.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/@nodelib/fs.stat/out/adapters'
@ ./packages/cli/node_modules/@nodelib/fs.stat/out/adapters/fs.js 3:11-24
@ ./packages/cli/node_modules/@nodelib/fs.stat/out/managers/options.js
@ ./packages/cli/node_modules/@nodelib/fs.stat/out/index.js
@ ./packages/cli/node_modules/fast-glob/out/adapters/fs-stream.js
@ ./packages/cli/node_modules/fast-glob/out/providers/reader-stream.js
@ ./packages/cli/node_modules/fast-glob/out/index.js
@ ./packages/cli/node_modules/fast-glob/index.js
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/chardet/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/chardet'
@ ./packages/cli/node_modules/chardet/index.js 2:9-22
@ ./packages/cli/node_modules/external-editor/main/index.js
@ ./packages/cli/node_modules/inquirer/lib/prompts/editor.js
@ ./packages/cli/node_modules/inquirer/lib/inquirer.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/external-editor/main/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/external-editor/main'
@ ./packages/cli/node_modules/external-editor/main/index.js 13:7-20
@ ./packages/cli/node_modules/inquirer/lib/prompts/editor.js
@ ./packages/cli/node_modules/inquirer/lib/inquirer.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/fs.realpath/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/fs.realpath'
@ ./packages/cli/node_modules/fs.realpath/index.js 8:9-22
@ ./packages/cli/node_modules/glob/glob.js
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/fs.realpath/old.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/fs.realpath'
@ ./packages/cli/node_modules/fs.realpath/old.js 24:9-22
@ ./packages/cli/node_modules/fs.realpath/index.js
@ ./packages/cli/node_modules/glob/glob.js
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/glob/glob.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/glob'
@ ./packages/cli/node_modules/glob/glob.js 43:9-22
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/glob/sync.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/glob'
@ ./packages/cli/node_modules/glob/sync.js 4:9-22
@ ./packages/cli/node_modules/glob/glob.js
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/globby/gitignore.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/globby'
@ ./packages/cli/node_modules/globby/gitignore.js 2:11-24
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/handlebars/lib/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/handlebars/lib'
@ ./packages/cli/node_modules/handlebars/lib/index.js 17:11-24
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/isbinaryfile/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/isbinaryfile'
@ ./packages/cli/node_modules/isbinaryfile/index.js 1:9-22
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/mkdirp/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/mkdirp'
@ ./packages/cli/node_modules/mkdirp/index.js 2:9-22
@ ./packages/cli/node_modules/node-plop/lib/fs-promise-proxy.js
@ ./packages/cli/node_modules/node-plop/lib/actions/append.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/node-plop/lib/fs-promise-proxy.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/node-plop/lib'
@ ./packages/cli/node_modules/node-plop/lib/fs-promise-proxy.js 12:10-23
@ ./packages/cli/node_modules/node-plop/lib/actions/append.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/node-plop/lib/node-plop.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/node-plop/lib'
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js 7:10-23
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/node-plop/lib/actions'
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js 15:10-23
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/path-type/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/path-type'
@ ./packages/cli/node_modules/path-type/index.js 2:11-24
@ ./packages/cli/node_modules/dir-glob/index.js
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/resolve/lib/node-modules-paths.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/resolve/lib'
@ ./packages/cli/node_modules/resolve/lib/node-modules-paths.js 2:9-22
@ ./packages/cli/node_modules/resolve/lib/sync.js
@ ./packages/cli/node_modules/resolve/index.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/resolve/lib/sync.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/resolve/lib'
@ ./packages/cli/node_modules/resolve/lib/sync.js 2:9-22
@ ./packages/cli/node_modules/resolve/index.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/resolve/lib/async.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/resolve/lib'
@ ./packages/cli/node_modules/resolve/lib/async.js 2:9-22
@ ./packages/cli/node_modules/resolve/index.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/rimraf/rimraf.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/rimraf'
@ ./packages/cli/node_modules/rimraf/rimraf.js 6:9-22
@ ./packages/cli/node_modules/del/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/_common-action-add-file.js
@ ./packages/cli/node_modules/node-plop/lib/actions/add.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/snapdragon/lib/source-maps.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/snapdragon/lib'
@ ./packages/cli/node_modules/snapdragon/lib/source-maps.js 3:9-22
@ ./packages/cli/node_modules/snapdragon/lib/compiler.js
@ ./packages/cli/node_modules/snapdragon/index.js
@ ./packages/cli/node_modules/micromatch/lib/utils.js
@ ./packages/cli/node_modules/micromatch/index.js
@ ./packages/cli/node_modules/fast-glob/out/utils/pattern.js
@ ./packages/cli/node_modules/fast-glob/out/managers/tasks.js
@ ./packages/cli/node_modules/fast-glob/out/index.js
@ ./packages/cli/node_modules/fast-glob/index.js
@ ./packages/cli/node_modules/globby/index.js
@ ./packages/cli/node_modules/node-plop/lib/actions/addMany.js
@ ./packages/cli/node_modules/node-plop/lib/actions/index.js
@ ./packages/cli/node_modules/node-plop/lib/generator-runner.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/tmp/lib/tmp.js
Module not found: Error: Can't resolve 'fs' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/tmp/lib'
@ ./packages/cli/node_modules/tmp/lib/tmp.js 12:11-24
@ ./packages/cli/node_modules/external-editor/main/index.js
@ ./packages/cli/node_modules/inquirer/lib/prompts/editor.js
@ ./packages/cli/node_modules/inquirer/lib/inquirer.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
ERROR in ./packages/cli/node_modules/inquirer/lib/ui/baseUI.js
Module not found: Error: Can't resolve 'readline' in '/Users/splincode/Documents/Develop/store/packages/cli/node_modules/inquirer/lib/ui'
@ ./packages/cli/node_modules/inquirer/lib/ui/baseUI.js 4:15-34
@ ./packages/cli/node_modules/inquirer/lib/ui/prompt.js
@ ./packages/cli/node_modules/inquirer/lib/inquirer.js
@ ./packages/cli/node_modules/node-plop/lib/node-plop.js
@ ./packages/cli/node_modules/node-plop/lib/index.js
@ ./packages/cli/tests/cli.spec.ts
@ ./packages sync \.spec\.ts$
@ ./test.ts
Add ESLint in a build process instead of JSHint in a IDE/Text editor.
I've been adding Plop to my projects over the last few months, and something I've been wanting is an easy way to transform the template output before writing the file. Oftentimes it would be easier/faster to drop some code into the action, rather than abandon the default actions to write a Custom Action Function or a new action.
Use cases include linting and formatting, or making a one-off change instead of creating and loading a new Handlebars helper.
I found one issue that might relate to this: plopjs/plop#80
One way to accomplish this would be to add an optional transform()
function to the actions add
, addMany
, and modify
. It would take the template output and the Inquirer data, and should return or resolve the final file contents as a string.
function transform(templateOutput: string, data: any): string | Promise<string>
A quick look suggests it would be trivial to implement.
node-plop/src/actions/_common-action-add-file.js
Lines 36 to 42 in 7b53773
I've got some OSS time this week, so if there's no objections I can put together a pull request.
Please update your npm
package from 0.13.0
to the newest 0.15.0
. There are a few fixes in 0.15.0
that my project relies on and trying to share my fixes to others are difficult
I think could be a good Idea to refactor a plop-base.js. Use ES6 standard modules and ES Classes. Also use const or let (depend on the case) instead of var. What do you think @amwmedia ?
Of course, I will fork the project, open a branch referring to this issue and push a pull request.
I mention you because here and I do not want to step on your work.
Sometimes one does not want to have a single file with each
, but wants multiple files instead.
In the example below I try to render the same template multiple times but with the different data. parents
is an array produced by checkbox
prompt.
const actions = _.map(parents, parent => ({
type: 'add',
path: `migrations/model_belongs_to_${parent}.js`,
templateFile: `templates/belongs_to.hbs`,
data: { parent },
})),
In my case the generated files have the same parent
value -- the first one from the array.
It seems this commit ac4bcc4 has "fixed" such a behavior.
I can fully understand why we prevent overwriting the answers gathered by inquirer, but that code does a bit more than that.
4.0.0
to 4.0.1
.This version is covered by your current version range and after updating it in your project the build failed.
eslint-plugin-standard is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 8 commits.
116eb98
4.0.1
5f37f70
HACK: disable failing tests
64d4df8
standard
cfa02fc
mocha@6
093ca7a
eslint@6
900b256
Merge pull request #30 from limpid-kzonix/master
f9de5c3
add missing comma-separators in example of eslint-rules.
deb1a2a
remove gitignore
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
🚨 You need to enable Continuous Integration on all branches of this repository. 🚨
To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.
Since we did not receive a CI status on the greenkeeper/initial
branch, we assume that you still need to configure it.
If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/
.
We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.
Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial
branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.
As the ava documentation says, it can not transpile imported modules, but they suggest a workaround to achieve it.
I suppose that the purpose of the script that execute the command npm run clean
is for delete the /lib
folder.
I guess a cli-command like rm -rf /lib
could do the same job. And you save a script file for it. Let me your opinion about it 😄 . If you like the change, I leave a PR implemented #12 , if not just reject 😉
I notice that the npm scripts are not pretty clear and I will made a little suggestions to change.
This is a request to update the Inquirer dependency to the latest version.
The primary reason is to have this PR integrated in so that we can reference the answers hash in the filter function.
Depending on your bandwidth, I may have time to assign this to myself and jump on the update sometime soon.
https://github.com/amwmedia/node-plop/blob/master/src/actions/addMany.js#L39
Globby has a dot option that I believe would fix this
Hi was having node-plop version 0.16.0 in my application.
During App scan I found some issues of security vulnerabilities which were related to handlebars packages. Since the parent of handlebars was node-plop hence I tried to update node-plop package to the latest 0.23.0 and then started to get some issues -
Error: ENOENT: no such file or directory, open 'D:\home\vcap\app\server\certs\IBMid\blueid-server.crt'
at Object.openSync (fs.js:443:3)
There is no path which is specified above.
Kindly look into it and send updates on the same.
The bundled .d.ts file tries to import type declarations for inquirer. This means that @types/inquirer must be declared as a dependency, not a devDependency. Otherwise, anyone trying to use node-plop will get TypeScript errors about missing declarations.
This is a common point of confusion, so here's a link where I explained this a few days ago:
https://www.reddit.com/r/typescript/comments/byar8w/tool_to_tell_me_which_types_deps_should_be_deps/eqfhsrf/
Here's an official explanation from the Typescript team: microsoft/types-publisher#81
It would be such a huge help if you could add typings to the repo.
https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html
I assume, you'd be faster than me :) Anyway, it's also possible that I'll try to add typings in the near future.
Babel is using an important amount of plugins. In order to minimize this list of plugins, I suggest using a Babel ES2015 preset that include all these plugins.
I propose the following to keep it backwards compatible
return Object.assign({}, generator, {
runActions: (data) => runner.runGeneratorActions(generator, data),
runInputs: () => runner.runGeneratorInputs(generator),
runPrompts: () => runner.runGeneratorPrompts(generator)
});
Then in generator-runner
allow for a more general inputs
method
const runGeneratorInputs = co.wrap(function* (genObject) {
if (genObject.inputs == null) {
throw Error(`${genObject.name} has no prompts`);
}
return yield genObject.inputs(genObject);
});
return {
runGeneratorActions,
runGeneratorInputs,
runGeneratorPrompts
};
Hey,
We ran into an issue where files such as Dockerfile
or .babelrc
are ignored because of https://github.com/amwmedia/node-plop/blob/17fb3ff9ee6f61ba9b64751234b0e87714ec7de5/src/actions/addMany.js#L47.
I'm happy to open a PR that removes the isFile
function together with its use at https://github.com/amwmedia/node-plop/blob/17fb3ff9ee6f61ba9b64751234b0e87714ec7de5/src/actions/addMany.js#L41.
Before I do though, I want to make sure that PR would get accepted. It's quite possible that isFile
function is required 🤔.
I'm getting the following warning during node-plop
install:
warning plop > node-plop > @types/[email protected]: This is a stub types definition. globby provides its own type definitions, so you do not need this installed.
warning plop > node-plop > @types/[email protected]: This is a stub types definition. handlebars provides its own type definitions, so you do not need this installed.
So I assume we can basically remove @types/globby
and @types/handlebars
from package.json
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.