How to use node-plop - 3 common examples

To help you get started, we’ve selected a few node-plop examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / just / packages / create-just / src / plop.ts View on Github external
export async function getPlopGenerator(plopfilePath: string, destBasePath: string, stackName: string) {
  const plopfile = path.join(plopfilePath, 'plopfile.js');
  const plop = nodePlop(plopfile, { destBasePath, force: false });

  // Automatically inject some plop helpers
  const justPlopHelpers = require.resolve('just-plop-helpers');
  (plop as any).load(justPlopHelpers);

  let generator = plop.getGenerator(`repo:${stackName}`) as any;

  // Automatically inject a task of running the repo:parent actions
  if (generator.parent) {
    plop.setActionType('repo:parent', async (answers, _config, _plop) => {
      const parentPlopPath = (await downloadPackage(generator.parent))!;
      const parentPlopFilePath = path.join(parentPlopPath, 'plopfile.js');
      const parentPlop = nodePlop(parentPlopFilePath, { destBasePath, force: false });

      (parentPlop as any).load(justPlopHelpers);
github gramps-graphql / gramps-cli / bin / create / create.js View on Github external
export const handler = async argv => {
  const plopPath = path.resolve(__dirname, './plopfile.js');
  const plop = nodePlop(plopPath);
  const generator = plop.getGenerator('source');
  generator
    .runPrompts(argv.name ? [argv.name] : [])
    .then(generator.runActions)
    .then(obj => {
      obj.changes.forEach(({ path }) => console.log('[SUCCESS]', path));
      obj.failures.forEach(({ error }) => console.log('[FAIL]', error));
      console.log(`Created data-source-${argv.name}`);
    });
};
github microsoft / just / packages / create-just / src / plop.ts View on Github external
plop.setActionType('repo:parent', async (answers, _config, _plop) => {
      const parentPlopPath = (await downloadPackage(generator.parent))!;
      const parentPlopFilePath = path.join(parentPlopPath, 'plopfile.js');
      const parentPlop = nodePlop(parentPlopFilePath, { destBasePath, force: false });

      (parentPlop as any).load(justPlopHelpers);

      const parentGenerator = parentPlop.getGenerator(`repo:${generator.parent}`) as any;
      const results = await parentGenerator.runActions(answers);

      if (results.changes) {
        return results.changes.map(change => change.path).join('\n');
      }
    });
  }

node-plop

programmatic plopping for fun and profit

MIT
Latest version published 1 year ago

Package Health Score

78 / 100
Full package analysis

Popular node-plop functions