@c9up/spectrum 0.1.16 → 0.1.17
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/configure.d.ts +6 -0
- package/dist/configure.d.ts.map +1 -1
- package/dist/configure.js +2 -23
- package/dist/configure.js.map +1 -1
- package/dist/stubs.d.ts +14 -0
- package/dist/stubs.d.ts.map +1 -0
- package/dist/stubs.js +15 -0
- package/dist/stubs.js.map +1 -0
- package/package.json +4 -3
- package/src/configure.ts +9 -26
- package/src/stubs.ts +16 -0
- package/stubs/config/logger.stub +25 -0
package/dist/configure.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ interface Codemods {
|
|
|
4
4
|
writeFile(filePath: string, content: string, options?: {
|
|
5
5
|
force?: boolean;
|
|
6
6
|
}): Promise<void>;
|
|
7
|
+
makeUsingStub(stubsRoot: string, stubPath: string, state?: Record<string, string | number | boolean>, options?: {
|
|
8
|
+
force?: boolean;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
path: string;
|
|
11
|
+
contents: string;
|
|
12
|
+
}>;
|
|
7
13
|
}
|
|
8
14
|
export declare function configure(codemods: Codemods): Promise<void>;
|
|
9
15
|
export {};
|
package/dist/configure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAEA,UAAU,QAAQ;IACjB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACR,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,aAAa,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EACjD,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC3B,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/C;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAGjE"}
|
package/dist/configure.js
CHANGED
|
@@ -1,27 +1,6 @@
|
|
|
1
|
+
import { stubsRoot } from "./stubs.js";
|
|
1
2
|
export async function configure(codemods) {
|
|
2
3
|
await codemods.addProvider("@c9up/spectrum/provider");
|
|
3
|
-
await codemods.
|
|
4
|
-
|
|
5
|
-
const inProduction = process.env.NODE_ENV === 'production'
|
|
6
|
-
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
default: 'app',
|
|
9
|
-
loggers: {
|
|
10
|
-
app: {
|
|
11
|
-
enabled: true,
|
|
12
|
-
name: process.env.APP_NAME ?? 'app',
|
|
13
|
-
// LOG_LEVEL comes from outside the program, so it is checked rather than
|
|
14
|
-
// asserted: anything that is not a level reads as 'info'.
|
|
15
|
-
level: logLevel(process.env.LOG_LEVEL),
|
|
16
|
-
transport: {
|
|
17
|
-
targets: targets()
|
|
18
|
-
.pushIf(!inProduction, targets.pretty())
|
|
19
|
-
.pushIf(inProduction, targets.file({ destination: 1 }))
|
|
20
|
-
.toArray(),
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
})
|
|
25
|
-
`);
|
|
4
|
+
await codemods.makeUsingStub(stubsRoot, "config/logger.stub");
|
|
26
5
|
}
|
|
27
6
|
//# sourceMappingURL=configure.js.map
|
package/dist/configure.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../src/configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAkBvC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAkB;IACjD,MAAM,QAAQ,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IACtD,MAAM,QAAQ,CAAC,aAAa,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/stubs.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where this package's stubs live.
|
|
3
|
+
*
|
|
4
|
+
* Its own module, as upstream keeps it: a stub root is a path a package
|
|
5
|
+
* publishes, and a caller importing it should not have to import the
|
|
6
|
+
* configure hook to get it.
|
|
7
|
+
*
|
|
8
|
+
* `import.meta.dirname` rather than a URL — upstream reads it straight off
|
|
9
|
+
* `import.meta`, and deriving it from `import.meta.url` breaks wherever that
|
|
10
|
+
* is not a `file://` URL, which is what a test runner serving modules over
|
|
11
|
+
* HTTP hands you.
|
|
12
|
+
*/
|
|
13
|
+
export declare const stubsRoot: string;
|
|
14
|
+
//# sourceMappingURL=stubs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../src/stubs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,eAAO,MAAM,SAAS,QAA2C,CAAC"}
|
package/dist/stubs.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where this package's stubs live.
|
|
3
|
+
*
|
|
4
|
+
* Its own module, as upstream keeps it: a stub root is a path a package
|
|
5
|
+
* publishes, and a caller importing it should not have to import the
|
|
6
|
+
* configure hook to get it.
|
|
7
|
+
*
|
|
8
|
+
* `import.meta.dirname` rather than a URL — upstream reads it straight off
|
|
9
|
+
* `import.meta`, and deriving it from `import.meta.url` breaks wherever that
|
|
10
|
+
* is not a `file://` URL, which is what a test runner serving modules over
|
|
11
|
+
* HTTP hands you.
|
|
12
|
+
*/
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
export const stubsRoot = join(import.meta.dirname, "..", "stubs");
|
|
15
|
+
//# sourceMappingURL=stubs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stubs.js","sourceRoot":"","sources":["../src/stubs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c9up/spectrum",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "Spectrum — structured logging for the Ream framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@c9up/ream": "^0.2.
|
|
32
|
+
"@c9up/ream": "^0.2.26"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@biomejs/biome": "^2.5.12",
|
|
36
|
-
"@c9up/ream": "^0.2.
|
|
36
|
+
"@c9up/ream": "^0.2.25",
|
|
37
37
|
"@types/node": "^22.20.1",
|
|
38
38
|
"@vitest/coverage-v8": "4.1.11",
|
|
39
39
|
"typescript": "^6.0.3",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"files": [
|
|
47
47
|
"src",
|
|
48
48
|
"dist",
|
|
49
|
+
"stubs",
|
|
49
50
|
"README.md",
|
|
50
51
|
"LICENSE"
|
|
51
52
|
],
|
package/src/configure.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { stubsRoot } from "./stubs.js";
|
|
2
|
+
|
|
1
3
|
interface Codemods {
|
|
2
4
|
addProvider(importPath: string): Promise<void>;
|
|
3
5
|
addEnvVars(vars: Record<string, string>): Promise<void>;
|
|
@@ -6,34 +8,15 @@ interface Codemods {
|
|
|
6
8
|
content: string,
|
|
7
9
|
options?: { force?: boolean },
|
|
8
10
|
): Promise<void>;
|
|
11
|
+
makeUsingStub(
|
|
12
|
+
stubsRoot: string,
|
|
13
|
+
stubPath: string,
|
|
14
|
+
state?: Record<string, string | number | boolean>,
|
|
15
|
+
options?: { force?: boolean },
|
|
16
|
+
): Promise<{ path: string; contents: string }>;
|
|
9
17
|
}
|
|
10
18
|
|
|
11
19
|
export async function configure(codemods: Codemods): Promise<void> {
|
|
12
20
|
await codemods.addProvider("@c9up/spectrum/provider");
|
|
13
|
-
await codemods.
|
|
14
|
-
"config/logger.ts",
|
|
15
|
-
`import { defineConfig, logLevel, targets } from '@c9up/spectrum'
|
|
16
|
-
|
|
17
|
-
const inProduction = process.env.NODE_ENV === 'production'
|
|
18
|
-
|
|
19
|
-
export default defineConfig({
|
|
20
|
-
default: 'app',
|
|
21
|
-
loggers: {
|
|
22
|
-
app: {
|
|
23
|
-
enabled: true,
|
|
24
|
-
name: process.env.APP_NAME ?? 'app',
|
|
25
|
-
// LOG_LEVEL comes from outside the program, so it is checked rather than
|
|
26
|
-
// asserted: anything that is not a level reads as 'info'.
|
|
27
|
-
level: logLevel(process.env.LOG_LEVEL),
|
|
28
|
-
transport: {
|
|
29
|
-
targets: targets()
|
|
30
|
-
.pushIf(!inProduction, targets.pretty())
|
|
31
|
-
.pushIf(inProduction, targets.file({ destination: 1 }))
|
|
32
|
-
.toArray(),
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
`,
|
|
38
|
-
);
|
|
21
|
+
await codemods.makeUsingStub(stubsRoot, "config/logger.stub");
|
|
39
22
|
}
|
package/src/stubs.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where this package's stubs live.
|
|
3
|
+
*
|
|
4
|
+
* Its own module, as upstream keeps it: a stub root is a path a package
|
|
5
|
+
* publishes, and a caller importing it should not have to import the
|
|
6
|
+
* configure hook to get it.
|
|
7
|
+
*
|
|
8
|
+
* `import.meta.dirname` rather than a URL — upstream reads it straight off
|
|
9
|
+
* `import.meta`, and deriving it from `import.meta.url` breaks wherever that
|
|
10
|
+
* is not a `file://` URL, which is what a test runner serving modules over
|
|
11
|
+
* HTTP hands you.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
|
|
16
|
+
export const stubsRoot = join(import.meta.dirname, "..", "stubs");
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: config/logger.ts
|
|
3
|
+
---
|
|
4
|
+
import { defineConfig, logLevel, targets } from '@c9up/spectrum'
|
|
5
|
+
|
|
6
|
+
const inProduction = process.env.NODE_ENV === 'production'
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
default: 'app',
|
|
10
|
+
loggers: {
|
|
11
|
+
app: {
|
|
12
|
+
enabled: true,
|
|
13
|
+
name: process.env.APP_NAME ?? 'app',
|
|
14
|
+
// LOG_LEVEL comes from outside the program, so it is checked rather than
|
|
15
|
+
// asserted: anything that is not a level reads as 'info'.
|
|
16
|
+
level: logLevel(process.env.LOG_LEVEL),
|
|
17
|
+
transport: {
|
|
18
|
+
targets: targets()
|
|
19
|
+
.pushIf(!inProduction, targets.pretty())
|
|
20
|
+
.pushIf(inProduction, targets.file({ destination: 1 }))
|
|
21
|
+
.toArray(),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
})
|