node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`should show help information on help flag 1`] = `
"
Usage:
$ plop Select from a list of available generators
$ plop <name> Run a generator registered under that name
$ plop <name> [input] Run the generator with input data to bypass prompts
Options:
-h, --help Show this help display
-t, --show-type-names Show type names instead of abbreviations
-i, --init Generate a basic plopfile.js
-v, --version Print current version
-f, --force Run the generator forcefully
------------------------------------------------------
⚠ danger waits for those who venture below the line
--plopfile Path to the plopfile
--cwd Directory from which relative paths are calculated against while locating the plopfile
--preload String or array of modules to require before running plop
--dest Output to this directory instead of the plopfile's parent directory
--no-progress Disable the progress bar
Examples:
$ plop
$ plop component
$ plop component "name of component"
"
`;

21
server/node_modules/plop/tests/action-failure.spec.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import { resolve, dirname } from "node:path";
import { waitFor } from "cli-testing-library";
import { renderPlop } from "./render.js";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
test("should exit with code 1 when failed actions", async () => {
const { findByText, userEvent } = await renderPlop([], {
cwd: resolve(__dirname, "./examples/action-failure"),
});
expect(await findByText("What is your name?")).toBeInTheConsole();
await userEvent.keyboard("Joe");
expect(await findByText("Joe")).toBeInTheConsole();
await userEvent.keyboard("[Enter]");
const actionOutput = await findByText("Action failed");
await waitFor(() =>
expect(actionOutput.hasExit()).toStrictEqual({ exitCode: 1 }),
);
});

56
server/node_modules/plop/tests/actions.spec.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
import { resolve, dirname } from "node:path";
import { waitFor } from "cli-testing-library";
import * as fs from "node:fs";
import { renderPlop } from "./render.js";
import { getFileHelper } from "./file-helper.js";
const { getFilePath } = getFileHelper();
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
test("Plop to add and rename files", async () => {
const expectedFilePath = await getFilePath(
"./examples/add-action/output/new-output.txt",
);
const { findByText, userEvent } = await renderPlop(["addAndNameFile"], {
cwd: resolve(__dirname, "./examples/add-action"),
});
expect(await findByText("What should the file name be?")).toBeInTheConsole();
await userEvent.keyboard("new-output");
await userEvent.keyboard("[Enter]");
await waitFor(() => fs.promises.stat(expectedFilePath));
const data = fs.readFileSync(expectedFilePath, "utf8");
expect(data).toMatch(/Hello/);
});
test("Plop to add and change file contents", async () => {
const expectedFilePath = await getFilePath(
"./examples/add-action/output/new-output.txt",
);
const { findByText, userEvent } = await renderPlop(["addAndChangeFile"], {
cwd: resolve(__dirname, "./examples/add-action"),
});
expect(await findByText("What's your name?")).toBeInTheConsole();
await userEvent.keyboard("Corbin");
await userEvent.keyboard("[Enter]");
await waitFor(() => fs.promises.stat(expectedFilePath));
const data = await fs.promises.readFile(expectedFilePath, "utf8");
expect(data).toMatch(/Hi Corbin!/);
});
test.todo("Test modify");
test.todo("Test append");
test.todo("Test built-in helpers");
test.todo("Test custom helpers");

10
server/node_modules/plop/tests/config/setup.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
// require("cli-testing-library/extend-expect");
import { configure } from "cli-testing-library";
import "cli-testing-library/extend-expect";
configure({
asyncUtilTimeout: 8000,
renderAwaitTime: 4000,
errorDebounceTimeout: 4000,
});

46
server/node_modules/plop/tests/esm.spec.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
import { resolve, dirname } from "node:path";
import { renderPlop } from "./render.js";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
test("should load ESM file", async () => {
const { findByText, userEvent } = await renderPlop([], {
cwd: resolve(__dirname, "./examples/esm"),
});
expect(await findByText("What is your name?")).toBeInTheConsole();
await userEvent.keyboard("Joe");
expect(await findByText("Joe")).toBeInTheConsole();
await userEvent.keyboard("[Enter]");
});
test("should load MJS file", async () => {
const { findByText, userEvent } = await renderPlop([], {
cwd: resolve(__dirname, "./examples/mjs"),
});
expect(await findByText("What is your name?")).toBeInTheConsole();
await userEvent.keyboard("Joe");
expect(await findByText("Joe")).toBeInTheConsole();
await userEvent.keyboard("[Enter]");
});
test("should load CJS file", async () => {
const { findByText, userEvent } = await renderPlop([], {
cwd: resolve(__dirname, "./examples/cjs"),
});
expect(await findByText("What is your name?")).toBeInTheConsole();
await userEvent.keyboard("Joe");
expect(await findByText("Joe")).toBeInTheConsole();
await userEvent.keyboard("[Enter]");
});
test("should load JS module='commonjs' file", async () => {
const { findByText, userEvent } = await renderPlop([], {
cwd: resolve(__dirname, "./examples/cjs-js"),
});
expect(await findByText("What is your name?")).toBeInTheConsole();
await userEvent.keyboard("Joe");
expect(await findByText("Joe")).toBeInTheConsole();
await userEvent.keyboard("[Enter]");
});

View File

@@ -0,0 +1,7 @@
{
"name": "plop-example-action-failure",
"type": "module",
"engines": {
"node": ">=18"
}
}

View File

@@ -0,0 +1,17 @@
export default function (plop) {
plop.setGenerator("test", {
description: "this is a test",
prompts: [
{
type: "input",
name: "name",
message: "What is your name?",
},
],
actions: [
() => {
throw new Error("Action failed");
},
],
});
}

View File

View File

@@ -0,0 +1,7 @@
{
"name": "plop-example-add-action",
"type": "module",
"engines": {
"node": ">=18"
}
}

View File

@@ -0,0 +1,37 @@
export default function (plop) {
plop.setGenerator("addAndNameFile", {
description: "Name that file",
prompts: [
{
type: "input",
name: "fileName",
message: "What should the file name be?",
},
],
actions: [
{
type: "add",
path: "./output/{{fileName}}.txt",
templateFile: "./templates/to-add.txt",
},
],
});
plop.setGenerator("addAndChangeFile", {
description: "Name that file",
prompts: [
{
type: "input",
name: "name",
message: "What's your name?",
},
],
actions: [
{
type: "add",
path: "./output/new-output.txt",
templateFile: "./templates/to-add-change.txt",
},
],
});
}

View File

@@ -0,0 +1 @@
Hi {{name}}!

View File

@@ -0,0 +1 @@
Hello

View File

@@ -0,0 +1,7 @@
{
"name": "plop-example-prompts-only",
"type": "commonjs",
"engines": {
"node": ">=18"
}
}

View File

@@ -0,0 +1,30 @@
module.exports = function (plop) {
plop.setGenerator("test", {
description: "this is a test",
prompts: [
{
type: "input",
name: "name",
message: "What is your name?",
validate: function (value) {
if (/.+/.test(value)) {
return true;
}
return "name is required";
},
},
{
type: "checkbox",
name: "toppings",
message: "What pizza toppings do you like?",
choices: [
{ name: "Cheese", value: "cheese", checked: true },
{ name: "Pepperoni", value: "pepperoni" },
{ name: "Pineapple", value: "pineapple" },
{ name: "Mushroom", value: "mushroom" },
{ name: "Bacon", value: "bacon", checked: true },
],
},
],
});
};

View File

@@ -0,0 +1,7 @@
{
"name": "plop-example-prompts-only",
"type": "module",
"engines": {
"node": ">=18"
}
}

View File

@@ -0,0 +1,30 @@
module.exports = function (plop) {
plop.setGenerator("test", {
description: "this is a test",
prompts: [
{
type: "input",
name: "name",
message: "What is your name?",
validate: function (value) {
if (/.+/.test(value)) {
return true;
}
return "name is required";
},
},
{
type: "checkbox",
name: "toppings",
message: "What pizza toppings do you like?",
choices: [
{ name: "Cheese", value: "cheese", checked: true },
{ name: "Pepperoni", value: "pepperoni" },
{ name: "Pineapple", value: "pineapple" },
{ name: "Mushroom", value: "mushroom" },
{ name: "Bacon", value: "bacon", checked: true },
],
},
],
});
}

View File

@@ -0,0 +1,7 @@
{
"name": "plop-example-prompts-only",
"type": "module",
"engines": {
"node": ">=18"
}
}

View File

@@ -0,0 +1,30 @@
export default function (plop) {
plop.setGenerator("test", {
description: "this is a test",
prompts: [
{
type: "input",
name: "name",
message: "What is your name?",
validate: function (value) {
if (/.+/.test(value)) {
return true;
}
return "name is required";
},
},
{
type: "checkbox",
name: "toppings",
message: "What pizza toppings do you like?",
choices: [
{ name: "Cheese", value: "cheese", checked: true },
{ name: "Pepperoni", value: "pepperoni" },
{ name: "Pineapple", value: "pineapple" },
{ name: "Mushroom", value: "mushroom" },
{ name: "Bacon", value: "bacon", checked: true },
],
},
],
});
}

View File

@@ -0,0 +1,7 @@
{
"name": "plop-example",
"type": "module",
"engines": {
"node": ">=18"
}
}

View File

@@ -0,0 +1,250 @@
import path from "path";
import fs from "fs";
import inquirerDirectory from "inquirer-directory";
export default function (plop) {
// starting prompt can be customized to display what you want
// plop.setWelcomeMessage('[CUSTOM]'.yellow + ' What can I do for you?');
// helpers are passed through handlebars syntax and made
// available for use in the generator templates
// adds 4 dashes around some text (yes es6/es2015 is supported)
plop.addHelper("dashAround", (text) => "---- " + text + " ----");
// formats an array of options like you would write
// it, if you were speaking (one, two, and three)
plop.addHelper("wordJoin", function (words) {
return words.join(", ").replace(/(:?.*),/, "$1, and");
});
plop.addHelper("absPath", function (p) {
return path.resolve(plop.getPlopfilePath(), p);
});
// greet the user using a partial
plop.addPartial(
"salutation",
"{{ greeting }}, my name is {{ properCase name }} and I am {{ age }}.",
);
// load some additional helpers from a module installed using npm
plop.load("plop-pack-fancy-comments", {
prefix: "",
upperCaseHeaders: true,
commentStart: "",
commentEnd: "",
});
const delayLog = (msg) => (answers) =>
new Promise((resolve) => {
setTimeout(() => resolve(msg), 1000);
});
// setGenerator creates a generator that can be run with "plop generatorName"
plop.setGenerator("test", {
description: "this is a test",
prompts: [
{
type: "input",
name: "name",
message: "What is your name?",
validate: function (value) {
if (/.+/.test(value)) {
return true;
}
return "name is required";
},
},
{
type: "input",
name: "age",
message: "How old are you?",
validate: function (value) {
var digitsOnly = /\d+/;
if (digitsOnly.test(value)) {
return true;
}
return "Invalid age! Must be a number genius!";
},
},
{
type: "checkbox",
name: "toppings",
message: "What pizza toppings do you like?",
choices: [
{ name: "Cheese", value: "cheese", checked: true },
{ name: "Pepperoni", value: "pepperoni" },
{ name: "Pineapple", value: "pineapple" },
{ name: "Mushroom", value: "mushroom" },
{ name: "Bacon", value: "bacon", checked: true },
],
},
],
actions: [
`this is a comment`,
"this is another comment",
delayLog("delayed thing"),
delayLog("another delayed thing"),
delayLog("this was also delayed"),
{
type: "add",
path: "folder/{{dashCase name}}.txt",
templateFile: "templates/temp.txt",
abortOnFail: true,
},
function customAction(answers) {
// move the current working directory to the plop file path
// this allows this action to work even when the generator is
// executed from inside a subdirectory
process.chdir(plop.getPlopfilePath());
// custom function can be synchronous or async (by returning a promise)
var existsMsg = "psst {{name}}, change-me.txt already exists";
var copiedMsg = "hey {{name}}, I copied change-me.txt for you";
var changeFileName = "change-me.txt";
var changeFilePath =
plop.getDestBasePath() + "/folder/" + changeFileName;
// you can use plop.renderString to render templates
existsMsg = plop.renderString(existsMsg, answers);
copiedMsg = plop.renderString(copiedMsg, answers);
if (fs.existsSync(changeFilePath)) {
// returned value shows up in the console
return existsMsg;
} else {
// do a synchronous copy via node fs
fs.writeFileSync(
changeFilePath,
fs.readFileSync("templates/" + changeFileName),
);
return copiedMsg;
}
},
{
type: "modify",
path: "folder/change-me.txt",
pattern: /(-- APPEND ITEMS HERE --)/gi,
template: "$1\r\n{{name}}: {{age}}",
},
{
type: "modify",
path: "folder/change-me.txt",
pattern: /(-- PREPEND ITEMS HERE --)/gi,
templateFile: "templates/part.txt",
},
{
type: "modify",
path: "folder/change-me.txt",
pattern: /## replace name here ##/gi,
template: "replaced => {{dashCase name}}",
},
{
type: "modify",
path: "folder/change-me.txt",
skip(data) {
if (!data.toppings.includes("mushroom")) {
// Skip this action
return "Skipped replacing mushrooms";
} else {
// Continue with this action
return;
}
},
transform(fileContents, data) {
return fileContents.replace(/mushrooms/g, "pepperoni");
},
},
],
});
// adding a custom inquirer prompt type
plop.addPrompt("directory", inquirerDirectory);
plop.setGenerator("custom-prompt", {
description: "custom inquirer prompt example",
prompts: [
{
type: "input",
name: "fileName",
message: "Pick a file name:",
validate: function (value) {
if (/.+/.test(value)) {
return true;
}
return "file name is required";
},
},
{
type: "directory",
name: "path",
message: "where would you like to put this component?",
basePath: plop.getPlopfilePath(),
},
],
actions: [
function (data) {
console.log(data);
return "yay";
},
{
type: "add",
path: "{{absPath path}}/{{fileName}}.txt",
template: "{{absPath path}}/{{fileName}} plopped!",
},
],
});
// test with dynamic actions, regarding responses to prompts
plop.setGenerator("dynamic actions", {
description: "another test using an actions function",
prompts: [
{
type: "input",
name: "name",
message: "What is your name?",
validate: function (value) {
if (/.+/.test(value)) {
return true;
}
return "name is required";
},
},
{
type: "confirm",
name: "hasPotatoes",
message: "Do you want potatoes with your burger?",
},
],
actions: function (data) {
var actions = [
{
type: "add",
path: "folder/{{dashCase name}}-burger.txt",
templateFile: "templates/burger.txt",
abortOnFail: true,
},
];
if (data.hasPotatoes) {
actions = actions.concat([
{
type: "add",
path: "folder/{{dashCase name}}-potatoes.txt",
templateFile: "templates/potatoes.txt",
abortOnFail: true,
},
{
type: "modify",
path: "folder/{{dashCase name}}-burger.txt",
pattern: /(!\n)/gi,
template: "$1Your potatoes: {{dashCase name}}-potatoes.txt",
},
]);
}
return actions;
},
});
}

View File

@@ -0,0 +1,3 @@
{{ header 'Hello Burger Lover!' }}
Here's your burger {{ properCase name }}!

View File

@@ -0,0 +1,8 @@
the modify option in the test plop should add lines below for each run.
Use modify for things like adding script references to an HTML file.
-- APPEND ITEMS HERE --
+++++++++++++++++++++++++++++++++++++++
-- PREPEND ITEMS HERE --

View File

@@ -0,0 +1,2 @@
this is prepended! ## replace name here ##: {{age}}
$1

View File

@@ -0,0 +1 @@
Well {{ properCase name }}, it seems you asked for potatoes.

View File

@@ -0,0 +1,10 @@
{{ dashAround (properCase name) }}
{{> salutation greeting="Hello there" }}
{{#if toppings}}
on my pizza I like {{ wordJoin toppings }}
{{else}}
I don't like any toppings on my pizza (not human)
{{/if}}
generated by {{ pkg 'name' }}

View File

@@ -0,0 +1,7 @@
{
"name": "plop-example-prompts-only",
"type": "module",
"engines": {
"node": ">=18"
}
}

View File

@@ -0,0 +1,30 @@
export default function (plop) {
plop.setGenerator("test", {
description: "this is a test",
prompts: [
{
type: "input",
name: "name",
message: "What is your name?",
validate: function (value) {
if (/.+/.test(value)) {
return true;
}
return "name is required";
},
},
{
type: "checkbox",
name: "toppings",
message: "What pizza toppings do you like?",
choices: [
{ name: "Cheese", value: "cheese", checked: true },
{ name: "Pepperoni", value: "pepperoni" },
{ name: "Pineapple", value: "pineapple" },
{ name: "Mushroom", value: "mushroom" },
{ name: "Bacon", value: "bacon", checked: true },
],
},
],
});
}

View File

@@ -0,0 +1,7 @@
{
"name": "plop-example-prompts-only",
"type": "module",
"engines": {
"node": ">=18"
}
}

View File

@@ -0,0 +1,24 @@
export default function (plop) {
plop.setGenerator("test", {
description: "this is a test",
prompts: [
{
type: "input",
name: "name",
message: "What is your name?",
},
{
type: "checkbox",
name: "toppings",
message: "What pizza toppings do you like?",
choices: [
{ name: "Cheese", value: "cheese", checked: true },
{ name: "Pepperoni", value: "pepperoni" },
{ name: "Pineapple", value: "pineapple" },
{ name: "Mushroom", value: "mushroom" },
{ name: "Bacon", value: "bacon", checked: true },
],
},
],
});
}

View File

@@ -0,0 +1,6 @@
{
"name": "plop-example",
"dependencies": {
"typescript": "^5.2.2"
}
}

View File

@@ -0,0 +1,32 @@
import { NodePlopAPI } from "plop";
module.exports = function (plop: NodePlopAPI) {
plop.setGenerator("test", {
description: "this is a test",
prompts: [
{
type: "input",
name: "name",
message: "What is your name?",
validate: function (value) {
if (/.+/.test(value)) {
return true;
}
return "name is required";
},
},
{
type: "checkbox",
name: "toppings",
message: "What pizza toppings do you like?",
choices: [
{ name: "Cheese", value: "cheese", checked: true },
{ name: "Pepperoni", value: "pepperoni" },
{ name: "Pineapple", value: "pineapple" },
{ name: "Mushroom", value: "mushroom" },
{ name: "Bacon", value: "bacon", checked: true },
],
},
],
});
};

View File

@@ -0,0 +1,14 @@
{
"compilerOptions": {
// Required
"module": "esnext",
"esModuleInterop": true,
"moduleResolution": "node",
// Not required
"strict": true,
"baseUrl": "./",
"paths": {
"plop": ["../../src/plop.d.ts"]
}
}
}

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env node
import path from "node:path";
import minimist from "minimist";
import { Plop, run } from "../../../instrumented/src/plop.js";
const args = process.argv.slice(2);
const argv = minimist(args);
import { fileURLToPath } from "node:url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
Plop.prepare(
{
cwd: argv.cwd,
preload: argv.preload || [],
// In order for `plop` to always pick up the `plopfile.js` despite the CWD, you must use `__dirname`
configPath: path.join(__dirname, "plopfile.cjs"),
completion: argv.completion,
// This will merge the `plop` argv and the generator argv.
// This means that you don't need to use `--` anymore
},
function (env) {
Plop.execute(env, function (env) {
return run(env, undefined, true);
});
},
);

View File

View File

@@ -0,0 +1,7 @@
{
"name": "plop-example-wrap",
"type": "module",
"engines": {
"node": ">=18"
}
}

View File

@@ -0,0 +1,37 @@
module.exports = function (plop) {
plop.setGenerator("test", {
description: "this is a test",
prompts: [
{
type: "input",
name: "name",
message: "What is your name?",
validate: function (value) {
if (/.+/.test(value)) {
return true;
}
return "name is required";
},
},
{
type: "checkbox",
name: "toppings",
message: "What pizza toppings do you like?",
choices: [
{ name: "Cheese", value: "cheese", checked: true },
{ name: "Pepperoni", value: "pepperoni" },
{ name: "Pineapple", value: "pineapple" },
{ name: "Mushroom", value: "mushroom" },
{ name: "Bacon", value: "bacon", checked: true },
],
},
],
actions: [
{
type: "add",
path: "./output/added.txt",
templateFile: "./templates/to-add.txt",
},
],
});
};

View File

@@ -0,0 +1 @@
Hello

32
server/node_modules/plop/tests/file-helper.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
import fs from "node:fs";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
export const getFileHelper = () => {
let cleanupFile = null;
afterEach(() => {
if (!cleanupFile) return;
try {
fs.unlinkSync(cleanupFile);
} catch (e) {}
cleanupFile = null;
});
const getFilePath = async (path) => {
const expectedFilePath = resolve(__dirname, path);
cleanupFile = expectedFilePath;
try {
await fs.promises.unlink(cleanupFile);
} catch (e) {}
return expectedFilePath;
};
return {
getFilePath,
};
};

166
server/node_modules/plop/tests/input-processing.spec.js generated vendored Normal file
View File

@@ -0,0 +1,166 @@
import { resolve, dirname } from "node:path";
import { renderPlop } from "./render.js";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
test("should report a missing plopfile when not copied", async () => {
// The directory above this repo. We look up towards `plopfile.js` and found one at root otherwise.
const cwd = resolve(__dirname, "../../../..");
const { findByError } = await renderPlop([], { cwd });
expect(await findByError(/\[PLOP\] No plopfile found/)).toBeInTheConsole();
});
test("should show help information on help flag", async () => {
const { findByText } = await renderPlop(["--help"]);
const { stdoutArr } = await findByText("Usage:");
expect(stdoutArr.map((item) => item.contents).join("\n")).toMatchSnapshot();
});
test("should show version on version flag", async () => {
const { findByText } = await renderPlop(["--version"]);
expect(await findByText(/^[\w\.-]+$/)).toBeInTheConsole();
});
test("should show version on v flag", async () => {
const { findByText } = await renderPlop(["-v"]);
expect(await findByText(/^[\w\.-]+$/)).toBeInTheConsole();
});
test("should display inquirer prompts", async () => {
const { findByText, userEvent } = await renderPlop([], {
cwd: resolve(__dirname, "./examples/prompt-only"),
});
expect(await findByText("What is your name?")).toBeInTheConsole();
await userEvent.keyboard("Joe");
expect(await findByText("Joe")).toBeInTheConsole();
await userEvent.keyboard("[Enter]");
});
test("Should handle generator prompt", async () => {
const { findByText, clear, userEvent } = await renderPlop([""], {
cwd: resolve(__dirname, "./examples/javascript"),
});
await findByText("Please choose a generator");
clear();
await userEvent.keyboard("[ArrowUp]");
await userEvent.keyboard("[ArrowDown]");
await userEvent.keyboard("[Enter]");
expect(await findByText("this is a test")).toBeInTheConsole();
});
test("Should bypass generator prompt", async () => {
const { findByText } = await renderPlop(["test"], {
cwd: resolve(__dirname, "./examples/javascript"),
});
expect(await findByText("What is your name?")).toBeInTheConsole();
});
test("Should bypass input prompt with input", async () => {
const { queryByText, findByText } = await renderPlop(["Frank"], {
cwd: resolve(__dirname, "./examples/prompt-only"),
});
expect(await queryByText("What is your name?")).not.toBeInTheConsole();
expect(
await findByText("What pizza toppings do you like?"),
).toBeInTheConsole();
});
test("Should bypass input prompt with placeholder", async () => {
const { queryByText, findByText, userEvent } = await renderPlop(
["_", "Cheese"],
{
cwd: resolve(__dirname, "./examples/prompt-only"),
},
);
expect(await findByText("What is your name?")).toBeInTheConsole();
await userEvent.keyboard("[Enter]");
expect(
await queryByText("What pizza toppings do you like?"),
).not.toBeInTheConsole();
});
test("Should bypass input prompt with name", async () => {
const { queryByText, findByText } = await renderPlop(
["--", "--name", "Frank"],
{
cwd: resolve(__dirname, "./examples/prompt-only"),
},
);
expect(await queryByText("What is your name?")).not.toBeInTheConsole();
expect(
await findByText("What pizza toppings do you like?"),
).toBeInTheConsole();
});
test("Should bypass input prompt with empty string", async () => {
const { queryByText, findByText } = await renderPlop(["--", "--name", `""`], {
cwd: resolve(__dirname, "./examples/prompt-only"),
});
expect(await queryByText("What is your name?")).not.toBeInTheConsole();
expect(
await findByText("What pizza toppings do you like?"),
).toBeInTheConsole();
});
test("Should bypass checkbox prompt with input", async () => {
const { queryByText } = await renderPlop(["Frank", "Cheese"], {
cwd: resolve(__dirname, "./examples/prompt-only"),
});
expect(await queryByText("What is your name?")).not.toBeInTheConsole();
expect(
await queryByText("What pizza toppings do you like?"),
).not.toBeInTheConsole();
});
test("Should bypass checkbox prompt with placeholder", async () => {
const { queryByText, findByText } = await renderPlop(["Frank", "_"], {
cwd: resolve(__dirname, "./examples/prompt-only"),
});
expect(await queryByText("What is your name?")).not.toBeInTheConsole();
expect(
await findByText("What pizza toppings do you like?"),
).toBeInTheConsole();
});
test("Should bypass checkbox prompt with name", async () => {
const { queryByText, findByText, userEvent } = await renderPlop(
["--", "--toppings", "Cheese"],
{
cwd: resolve(__dirname, "./examples/prompt-only"),
},
);
expect(await findByText("What is your name?")).toBeInTheConsole();
await userEvent.keyboard("[Enter]");
expect(
await queryByText("What pizza toppings do you like?"),
).not.toBeInTheConsole();
});
test("Should bypass checkbox prompt with empty string", async () => {
const { queryByText, findByText, userEvent } = await renderPlop(
["--", "--toppings", `""`],
{
cwd: resolve(__dirname, "./examples/prompt-only"),
},
);
expect(await findByText("What is your name?")).toBeInTheConsole();
await userEvent.keyboard("[Enter]");
expect(
await queryByText("What pizza toppings do you like?"),
).not.toBeInTheConsole();
});
test.todo("Dynamic actions");

39
server/node_modules/plop/tests/render.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
import { render } from "cli-testing-library";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
/**
* @param {String} script
* @param {Array} args
* @param {Object} opts
*/
export function renderScript(script, args = [], opts = {}) {
const { cwd = __dirname } = opts;
return render(
resolve(__dirname, "../node_modules/.bin/nyc"),
["--silent", "node", script, ...args],
{
cwd,
spawnOpts: {
env: { ...process.env, NODE_ENV: "test" },
},
},
);
}
/**
* @param {Array} args
* @param {Object} opts
*/
export function renderPlop(args = [], opts = {}) {
return renderScript(
resolve(__dirname, "../instrumented/bin/plop.js"),
args,
opts,
);
}
export * from "cli-testing-library";

20
server/node_modules/plop/tests/typescript.spec.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import { resolve, dirname } from "node:path";
import { renderScript } from "./render.js";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const renderWrapper = (...props) => {
return renderScript(
resolve(__dirname, "./examples/wrap-plop/index.js"),
...props,
);
};
test("support typescript out of the box", async () => {
const { findByText } = await renderWrapper([""], {
cwd: resolve(__dirname, "./examples/typescript"),
});
expect(await findByText("What is your name?")).toBeInTheConsole();
});

74
server/node_modules/plop/tests/wrapper.spec.js generated vendored Normal file
View File

@@ -0,0 +1,74 @@
import fs from "node:fs";
import { resolve, dirname } from "node:path";
import { waitFor } from "cli-testing-library";
import { renderScript } from "./render.js";
import { getFileHelper } from "./file-helper.js";
const { getFilePath } = getFileHelper();
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const renderWrapper = (...props) => {
return renderScript(
resolve(__dirname, "./examples/wrap-plop/index.js"),
...props,
);
};
test("wrapper should show version on v flag", async () => {
const { findByText } = await renderWrapper(["-v"]);
expect(await findByText(/^[\w\.-]+$/)).toBeInTheConsole();
});
test("wrapper should prompts", async () => {
const { findByText, fireEvent } = await renderWrapper([""], {
cwd: resolve(__dirname, "./examples/wrap-plop"),
});
expect(await findByText("What is your name?")).toBeInTheConsole();
});
test("wrapper should bypass prompts with index", async () => {
const { findByText, queryByText, fireEvent } = await renderWrapper(
["Corbin"],
{
cwd: resolve(__dirname, "./examples/wrap-plop"),
},
);
expect(await queryByText("What is your name?")).not.toBeInTheConsole();
expect(
await findByText("What pizza toppings do you like?"),
).toBeInTheConsole();
});
test("wrapper should bypass prompts with name", async () => {
const { findByText, queryByText, fireEvent } = await renderWrapper(
["--name", "Corbin"],
{
cwd: resolve(__dirname, "./examples/wrap-plop"),
},
);
expect(await queryByText("What is your name?")).not.toBeInTheConsole();
expect(
await findByText("What pizza toppings do you like?"),
).toBeInTheConsole();
});
test("can run actions (add)", async () => {
const expectedFilePath = await getFilePath(
"./examples/wrap-plop/output/added.txt",
);
const { fireEvent } = await renderWrapper(["Test", "Cheese"], {
cwd: resolve(__dirname, "./examples/wrap-plop"),
});
await waitFor(() => fs.promises.stat(expectedFilePath));
const data = fs.readFileSync(expectedFilePath, "utf8");
expect(data).toMatch(/Hello/);
});