@impulselab/cli 0.1.0 → 0.1.2
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 +92 -9
- package/package.json +20 -9
- package/src/commands/add.test.ts +0 -147
- package/src/commands/add.ts +0 -335
- package/src/commands/init.ts +0 -114
- package/src/commands/list.ts +0 -79
- package/src/config/config-path.ts +0 -7
- package/src/config/has-config.ts +0 -9
- package/src/config/index.ts +0 -4
- package/src/config/read-config.ts +0 -20
- package/src/config/write-config.ts +0 -11
- package/src/config.test.ts +0 -64
- package/src/index.ts +0 -64
- package/src/installer.ts +0 -71
- package/src/registry/fetch-module-file.ts +0 -21
- package/src/registry/fetch-module-manifest.ts +0 -43
- package/src/registry/github-urls.ts +0 -13
- package/src/registry/index.ts +0 -5
- package/src/registry/list-available-modules.ts +0 -113
- package/src/registry/parse-module-id.ts +0 -30
- package/src/registry/registry.test.ts +0 -181
- package/src/schemas/impulse-config.ts +0 -21
- package/src/schemas/index.ts +0 -9
- package/src/schemas/module-dependency.ts +0 -3
- package/src/schemas/module-file.ts +0 -8
- package/src/schemas/module-manifest.ts +0 -23
- package/src/schemas/module-transform.ts +0 -15
- package/src/transforms/add-env.ts +0 -53
- package/src/transforms/add-nav-item.test.ts +0 -125
- package/src/transforms/add-nav-item.ts +0 -70
- package/src/transforms/append-export.test.ts +0 -50
- package/src/transforms/append-export.ts +0 -34
- package/src/transforms/index.ts +0 -32
- package/src/transforms/merge-schema.test.ts +0 -70
- package/src/transforms/merge-schema.ts +0 -35
- package/src/transforms/register-route.test.ts +0 -177
- package/src/transforms/register-route.ts +0 -47
- package/src/types.ts +0 -9
- package/tsconfig.json +0 -8
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import fsExtra from "fs-extra";
|
|
2
|
-
const { readFile, outputFile, pathExists } = fsExtra;
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Registers an oRPC route in the router file.
|
|
7
|
-
* target: path to the router file (e.g. "src/server/api/router.ts")
|
|
8
|
-
* value: the route line to add (e.g. "auth: authRouter")
|
|
9
|
-
*/
|
|
10
|
-
export async function registerRoute(
|
|
11
|
-
target: string,
|
|
12
|
-
value: string,
|
|
13
|
-
cwd: string,
|
|
14
|
-
dryRun: boolean
|
|
15
|
-
): Promise<void> {
|
|
16
|
-
const file = path.join(cwd, target);
|
|
17
|
-
|
|
18
|
-
if (!(await pathExists(file))) {
|
|
19
|
-
throw new Error(
|
|
20
|
-
`register-route: target file not found: ${target}. Please ensure your router file exists.`
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const content = await readFile(file, "utf-8");
|
|
25
|
-
if (content.includes(value)) return;
|
|
26
|
-
|
|
27
|
-
// Find the router object closing brace and insert before it.
|
|
28
|
-
// Anchored to start-of-line (multiline) with [ \t]* (no newlines) to avoid
|
|
29
|
-
// matching `}` on one line with `satisfies`/`as` on a subsequent line.
|
|
30
|
-
const routerPattern = /^([ \t]*\})[ \t]*(?:satisfies|as)\s/m;
|
|
31
|
-
const match = routerPattern.exec(content);
|
|
32
|
-
|
|
33
|
-
if (!match) {
|
|
34
|
-
throw new Error(
|
|
35
|
-
`register-route: could not find router closing brace in ${target}. Add "${value}" manually.`
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!dryRun) {
|
|
40
|
-
const insertPos = match.index;
|
|
41
|
-
const newContent =
|
|
42
|
-
content.slice(0, insertPos) +
|
|
43
|
-
` ${value},\n` +
|
|
44
|
-
content.slice(insertPos);
|
|
45
|
-
await outputFile(file, newContent, "utf-8");
|
|
46
|
-
}
|
|
47
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { ModuleFileSchema } from "./schemas/module-file";
|
|
2
|
-
export type { ModuleFile } from "./schemas/module-file";
|
|
3
|
-
export { ModuleDependencySchema } from "./schemas/module-dependency";
|
|
4
|
-
export { ModuleTransformSchema } from "./schemas/module-transform";
|
|
5
|
-
export type { ModuleTransform } from "./schemas/module-transform";
|
|
6
|
-
export { ModuleManifestSchema } from "./schemas/module-manifest";
|
|
7
|
-
export type { ModuleManifest } from "./schemas/module-manifest";
|
|
8
|
-
export { ImpulseConfigSchema } from "./schemas/impulse-config";
|
|
9
|
-
export type { ImpulseConfig } from "./schemas/impulse-config";
|