poe-code 3.0.335 → 3.0.337

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19139,11 +19139,11 @@ function formatOperation(operation) {
19139
19139
  switch (operation.type) {
19140
19140
  case "mkdir": {
19141
19141
  const recursiveFlag = operation.options?.recursive ? " -p" : "";
19142
- const command = `mkdir${recursiveFlag} ${operation.path}`;
19142
+ const command = `mkdir${recursiveFlag} ${quoteShellArgument(operation.path)}`;
19143
19143
  return renderOperationCommand(command, chalk.cyan, "# ensure");
19144
19144
  }
19145
19145
  case "unlink":
19146
- return renderOperationCommand(`rm ${operation.path}`, chalk.red, "# delete");
19146
+ return renderOperationCommand(`rm ${quoteShellArgument(operation.path)}`, chalk.red, "# delete");
19147
19147
  case "rm": {
19148
19148
  const flags = [];
19149
19149
  if (operation.options?.recursive) {
@@ -19153,31 +19153,31 @@ function formatOperation(operation) {
19153
19153
  flags.push("-f");
19154
19154
  }
19155
19155
  const flagSuffix = flags.length > 0 ? ` ${flags.join(" ")}` : "";
19156
- return renderOperationCommand(`rm${flagSuffix} ${operation.path}`, chalk.red, "# delete");
19156
+ return renderOperationCommand(`rm${flagSuffix} ${quoteShellArgument(operation.path)}`, chalk.red, "# delete");
19157
19157
  }
19158
19158
  case "copyFile":
19159
19159
  return renderOperationCommand(
19160
- `cp ${operation.from} ${operation.to}`,
19160
+ `cp ${quoteShellArgument(operation.from)} ${quoteShellArgument(operation.to)}`,
19161
19161
  chalk.cyan,
19162
19162
  "# copy"
19163
19163
  );
19164
19164
  case "chmod": {
19165
19165
  const mode = operation.mode.toString(8);
19166
19166
  return renderOperationCommand(
19167
- `chmod ${mode} ${operation.path}`,
19167
+ `chmod ${mode} ${quoteShellArgument(operation.path)}`,
19168
19168
  chalk.cyan,
19169
19169
  "# permissions"
19170
19170
  );
19171
19171
  }
19172
19172
  case "symlink":
19173
19173
  return renderOperationCommand(
19174
- `ln -s ${operation.target} ${operation.path}`,
19174
+ `ln -s ${quoteShellArgument(operation.target)} ${quoteShellArgument(operation.path)}`,
19175
19175
  chalk.cyan,
19176
19176
  "# symlink"
19177
19177
  );
19178
19178
  case "rename":
19179
19179
  return renderOperationCommand(
19180
- `mv ${operation.from} ${operation.to}`,
19180
+ `mv ${quoteShellArgument(operation.from)} ${quoteShellArgument(operation.to)}`,
19181
19181
  chalk.cyan,
19182
19182
  "# rename"
19183
19183
  );
@@ -19193,6 +19193,24 @@ function formatOperation(operation) {
19193
19193
  function renderOperationCommand(command, colorize, detail) {
19194
19194
  return `${colorize(command)} ${chalk.dim(detail)}`;
19195
19195
  }
19196
+ function quoteShellArgument(value) {
19197
+ if (value.length > 0 && isBareShellArgument(value)) {
19198
+ return value;
19199
+ }
19200
+ return `'${value.replaceAll("'", `'"'"'`)}'`;
19201
+ }
19202
+ function isBareShellArgument(value) {
19203
+ for (const char of value) {
19204
+ if (!isBareShellArgumentChar(char)) {
19205
+ return false;
19206
+ }
19207
+ }
19208
+ return true;
19209
+ }
19210
+ function isBareShellArgumentChar(char) {
19211
+ const code = char.charCodeAt(0);
19212
+ return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "/" || char === "." || char === "_" || char === "-" || char === ":" || char === "@" || char === "%" || char === "+" || char === "=" || char === ",";
19213
+ }
19196
19214
  function describeWriteChange(previous, next) {
19197
19215
  if (previous == null) {
19198
19216
  return "create";
@@ -19203,7 +19221,7 @@ function describeWriteChange(previous, next) {
19203
19221
  return "update";
19204
19222
  }
19205
19223
  function renderWriteCommand(path176, change) {
19206
- const command = `cat > ${path176}`;
19224
+ const command = `cat > ${quoteShellArgument(path176)}`;
19207
19225
  if (change === "create") {
19208
19226
  return renderOperationCommand(command, chalk.green, "# create");
19209
19227
  }
@@ -138093,7 +138111,7 @@ var init_package2 = __esm({
138093
138111
  "package.json"() {
138094
138112
  package_default2 = {
138095
138113
  name: "poe-code",
138096
- version: "3.0.335",
138114
+ version: "3.0.337",
138097
138115
  description: "CLI tool to configure Poe API for developer workflows.",
138098
138116
  type: "module",
138099
138117
  main: "./dist/index.js",