@mnci/cli 4.27.0 → 4.28.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 +85 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4873,6 +4873,86 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4873
4873
|
// src/project-scaffolding/react-app.use-case.ts
|
|
4874
4874
|
var import_node_fs15 = require("fs");
|
|
4875
4875
|
var import_node_path18 = require("path");
|
|
4876
|
+
|
|
4877
|
+
// src/project-scaffolding/react-app-example.algorithm.ts
|
|
4878
|
+
function reactAppExampleFiles(name) {
|
|
4879
|
+
return {
|
|
4880
|
+
"greeting/greeting.contract.ts": `/** What greeting someone returns. */
|
|
4881
|
+
export interface Greeting {
|
|
4882
|
+
readonly message: string
|
|
4883
|
+
}
|
|
4884
|
+
`,
|
|
4885
|
+
"greeting/greet.use-case.ts": `import type { Greeting } from './greeting.contract'
|
|
4886
|
+
|
|
4887
|
+
export function greet (name: string): Greeting {
|
|
4888
|
+
return { message: 'Hello, ' + name + '!' }
|
|
4889
|
+
}
|
|
4890
|
+
`,
|
|
4891
|
+
"greeting/greet.use-case.spec.ts": `import { greet } from './greet.use-case'
|
|
4892
|
+
|
|
4893
|
+
describe('greet', () => {
|
|
4894
|
+
it('greets a name', () => {
|
|
4895
|
+
expect(greet('world')).toEqual({ message: 'Hello, world!' })
|
|
4896
|
+
})
|
|
4897
|
+
})
|
|
4898
|
+
`,
|
|
4899
|
+
"greeting/greeting.component.tsx": `import { greet } from './greet.use-case'
|
|
4900
|
+
|
|
4901
|
+
export interface GreetingViewProps {
|
|
4902
|
+
readonly name: string
|
|
4903
|
+
}
|
|
4904
|
+
|
|
4905
|
+
export function GreetingView ({ name }: GreetingViewProps) {
|
|
4906
|
+
return <p>{greet(name).message}</p>
|
|
4907
|
+
}
|
|
4908
|
+
`,
|
|
4909
|
+
"greeting/greeting.component.spec.tsx": `import { render } from '@testing-library/react'
|
|
4910
|
+
|
|
4911
|
+
import { GreetingView } from './greeting.component'
|
|
4912
|
+
|
|
4913
|
+
describe('GreetingView', () => {
|
|
4914
|
+
it('shows the greeting', () => {
|
|
4915
|
+
const { getByText } = render(<GreetingView name='world' />)
|
|
4916
|
+
expect(getByText('Hello, world!')).toBeTruthy()
|
|
4917
|
+
})
|
|
4918
|
+
})
|
|
4919
|
+
`,
|
|
4920
|
+
"greeting/index.ts": `export * from './greeting.contract'
|
|
4921
|
+
export * from './greet.use-case'
|
|
4922
|
+
export * from './greeting.component'
|
|
4923
|
+
`,
|
|
4924
|
+
"app/app.component.tsx": `import { GreetingView } from '../greeting'
|
|
4925
|
+
|
|
4926
|
+
export function App () {
|
|
4927
|
+
return (
|
|
4928
|
+
<main>
|
|
4929
|
+
<GreetingView name='${name}' />
|
|
4930
|
+
</main>
|
|
4931
|
+
)
|
|
4932
|
+
}
|
|
4933
|
+
|
|
4934
|
+
export default App
|
|
4935
|
+
`,
|
|
4936
|
+
"app/app.component.spec.tsx": `import { render } from '@testing-library/react'
|
|
4937
|
+
|
|
4938
|
+
import App from './app.component'
|
|
4939
|
+
|
|
4940
|
+
describe('App', () => {
|
|
4941
|
+
it('should render successfully', () => {
|
|
4942
|
+
const { baseElement } = render(<App />)
|
|
4943
|
+
expect(baseElement).toBeTruthy()
|
|
4944
|
+
})
|
|
4945
|
+
|
|
4946
|
+
it('shows the greeting', () => {
|
|
4947
|
+
const { getByText } = render(<App />)
|
|
4948
|
+
expect(getByText('Hello, ${name}!')).toBeTruthy()
|
|
4949
|
+
})
|
|
4950
|
+
})
|
|
4951
|
+
`
|
|
4952
|
+
};
|
|
4953
|
+
}
|
|
4954
|
+
|
|
4955
|
+
// src/project-scaffolding/react-app.use-case.ts
|
|
4876
4956
|
var REACT_ENVIRONMENTS = ["dev", "uat", "prod"];
|
|
4877
4957
|
function reactEnvironmentFile(environment) {
|
|
4878
4958
|
return `# Vite compiles VITE_-prefixed vars into the '${environment}' bundle at build time.
|
|
@@ -4948,6 +5028,11 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
4948
5028
|
allowEnvFiles(workspaceRoot);
|
|
4949
5029
|
addNxTargets((0, import_node_path18.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
4950
5030
|
reshapeReactAppScaffold(reactAppRoot);
|
|
5031
|
+
(0, import_node_fs15.rmSync)((0, import_node_path18.join)(reactAppRoot, "src/app/nx-welcome.component.tsx"), { force: true });
|
|
5032
|
+
const example = reactAppExampleFiles(name);
|
|
5033
|
+
for (const [relative, contents] of Object.entries(example)) {
|
|
5034
|
+
writeFileEnsured((0, import_node_path18.join)(reactAppRoot, "src", relative), contents);
|
|
5035
|
+
}
|
|
4951
5036
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
4952
5037
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
4953
5038
|
}
|