next-action-plus 2.0.0 → 2.0.1
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/codemod/bin.js +15 -3
- package/package.json +1 -1
package/dist/codemod/bin.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// src/codemod/bin.ts
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
import { join, resolve } from "path";
|
|
6
|
+
|
|
3
7
|
// src/codemod/v2.ts
|
|
4
|
-
import ts from "typescript";
|
|
5
8
|
var REMOVED = ["ActionPlus", "ActionPlusError", "ActionPlusValidationError", "isActionPlusError", "isActionPlusValidationError", "schemaAvailable"];
|
|
6
9
|
var codemodV2 = (props) => {
|
|
7
|
-
const {
|
|
10
|
+
const { write: write2, typescript: ts } = props;
|
|
11
|
+
const project2 = ts.sys.resolvePath(props.project);
|
|
8
12
|
const configPath = ts.findConfigFile(project2, ts.sys.fileExists, "tsconfig.json");
|
|
9
13
|
if (!configPath) throw new Error(`next-action-plus codemod: no tsconfig.json found in ${project2}`);
|
|
10
14
|
const config = ts.getParsedCommandLineOfConfigFile(configPath, {}, { ...ts.sys, onUnRecoverableConfigFileDiagnostic: (diagnostic) => console.error(ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")) });
|
|
@@ -152,7 +156,15 @@ if (command !== "codemod" || version !== "v2") {
|
|
|
152
156
|
}
|
|
153
157
|
var write = rest.includes("--write");
|
|
154
158
|
var project = rest.find((argument) => !argument.startsWith("--")) ?? process.cwd();
|
|
155
|
-
var
|
|
159
|
+
var typescript = (() => {
|
|
160
|
+
try {
|
|
161
|
+
return createRequire(join(resolve(project), "package.json"))("typescript");
|
|
162
|
+
} catch {
|
|
163
|
+
console.error(`next-action-plus codemod: cannot find "typescript" in ${resolve(project)}. Run the codemod from your project folder, where typescript is installed.`);
|
|
164
|
+
return process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
})();
|
|
167
|
+
var report = codemodV2({ project, write, typescript });
|
|
156
168
|
for (const file of report.files) {
|
|
157
169
|
console.log(`
|
|
158
170
|
${write ? "changed" : "would change"} ${file.file} (${file.changes} edits)`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-action-plus",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Type-safe, secure-by-default Next.js Server Actions: any Standard Schema validator, gates for auth, typed errors, your own response shape, concurrency control, and drop-in adapters for auth, rate limits, locks, queues and telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|