@mnci/cli 4.24.0 → 4.25.0
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/cli.js +49 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2744,8 +2744,57 @@ function reshapeScaffoldSlice(projectRoot, name, extension, role, empty) {
|
|
|
2744
2744
|
(0, import_node_fs5.rmSync)(libDir, { recursive: true, force: true });
|
|
2745
2745
|
if (empty) {
|
|
2746
2746
|
emptySlice(projectRoot, sliceDir);
|
|
2747
|
+
} else if (role === "use-case") {
|
|
2748
|
+
writeWorkedExample(sliceDir, name, esm);
|
|
2747
2749
|
}
|
|
2748
2750
|
}
|
|
2751
|
+
function writeWorkedExample(sliceDir, name, esm) {
|
|
2752
|
+
const suffix = esm ? ".js" : "";
|
|
2753
|
+
writeFileEnsured(
|
|
2754
|
+
(0, import_node_path5.join)(sliceDir, `${name}.contract.ts`),
|
|
2755
|
+
`/** What greeting someone returns. */
|
|
2756
|
+
export interface Greeting {
|
|
2757
|
+
readonly message: string
|
|
2758
|
+
}
|
|
2759
|
+
`
|
|
2760
|
+
);
|
|
2761
|
+
writeFileEnsured(
|
|
2762
|
+
(0, import_node_path5.join)(sliceDir, `${name}.use-case.ts`),
|
|
2763
|
+
`import type { Greeting } from './${name}.contract${suffix}'
|
|
2764
|
+
|
|
2765
|
+
/**
|
|
2766
|
+
* Greets someone by name.
|
|
2767
|
+
*
|
|
2768
|
+
* @remarks
|
|
2769
|
+
* A worked example of a use case: one outcome, returning a contract. Replace it
|
|
2770
|
+
* with your own.
|
|
2771
|
+
*
|
|
2772
|
+
* @param name - Who to greet.
|
|
2773
|
+
* @returns The greeting.
|
|
2774
|
+
*/
|
|
2775
|
+
export function greet (name: string): Greeting {
|
|
2776
|
+
return { message: 'Hello, ' + name + '!' }
|
|
2777
|
+
}
|
|
2778
|
+
`
|
|
2779
|
+
);
|
|
2780
|
+
writeFileEnsured(
|
|
2781
|
+
(0, import_node_path5.join)(sliceDir, `${name}.use-case.spec.ts`),
|
|
2782
|
+
`import { greet } from './${name}.use-case${suffix}'
|
|
2783
|
+
|
|
2784
|
+
describe('greet', () => {
|
|
2785
|
+
it('greets by name', () => {
|
|
2786
|
+
expect(greet('world')).toEqual({ message: 'Hello, world!' })
|
|
2787
|
+
})
|
|
2788
|
+
})
|
|
2789
|
+
`
|
|
2790
|
+
);
|
|
2791
|
+
writeFileEnsured(
|
|
2792
|
+
(0, import_node_path5.join)(sliceDir, "index.ts"),
|
|
2793
|
+
`export * from './${name}.contract${suffix}'
|
|
2794
|
+
export * from './${name}.use-case${suffix}'
|
|
2795
|
+
`
|
|
2796
|
+
);
|
|
2797
|
+
}
|
|
2749
2798
|
function repointSpecifier(source, from, to) {
|
|
2750
2799
|
let result = source;
|
|
2751
2800
|
for (const quote of ["'", '"']) {
|