@mnci/cli 4.26.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 +190 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3970,6 +3970,105 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
3970
3970
|
|
|
3971
3971
|
// src/project-scaffolding/node.use-case.ts
|
|
3972
3972
|
var import_node_path12 = require("path");
|
|
3973
|
+
|
|
3974
|
+
// src/project-scaffolding/node-app-example.algorithm.ts
|
|
3975
|
+
var GREET_USE_CASE = `import type { Greeting } from './greeting.contract'
|
|
3976
|
+
|
|
3977
|
+
export function greet (name: string): Greeting {
|
|
3978
|
+
return { message: 'Hello, ' + name + '!' }
|
|
3979
|
+
}
|
|
3980
|
+
`;
|
|
3981
|
+
var GREETING_CONTRACT = `/** What greeting someone returns. */
|
|
3982
|
+
export interface Greeting {
|
|
3983
|
+
readonly message: string
|
|
3984
|
+
}
|
|
3985
|
+
`;
|
|
3986
|
+
var GREET_SPEC = `import { greet } from './greet.use-case'
|
|
3987
|
+
|
|
3988
|
+
describe('greet', () => {
|
|
3989
|
+
it('greets a name', () => {
|
|
3990
|
+
expect(greet('world')).toEqual({ message: 'Hello, world!' })
|
|
3991
|
+
})
|
|
3992
|
+
})
|
|
3993
|
+
`;
|
|
3994
|
+
var SLICE = {
|
|
3995
|
+
"hello/greet.use-case.ts": GREET_USE_CASE,
|
|
3996
|
+
"hello/greeting.contract.ts": GREETING_CONTRACT,
|
|
3997
|
+
"hello/greet.use-case.spec.ts": GREET_SPEC
|
|
3998
|
+
};
|
|
3999
|
+
function nodeAppExampleFiles(framework) {
|
|
4000
|
+
switch (framework) {
|
|
4001
|
+
case "none": {
|
|
4002
|
+
return {
|
|
4003
|
+
...SLICE,
|
|
4004
|
+
"hello/index.ts": "export * from './greeting.contract'\nexport * from './greet.use-case'\n",
|
|
4005
|
+
"main.ts": "import { greet } from './hello'\n\nconsole.log(greet('world').message)\n"
|
|
4006
|
+
};
|
|
4007
|
+
}
|
|
4008
|
+
case "express": {
|
|
4009
|
+
return {
|
|
4010
|
+
...SLICE,
|
|
4011
|
+
"hello/hello.handler.ts": `import type { Request, Response } from 'express'
|
|
4012
|
+
import { greet } from './greet.use-case'
|
|
4013
|
+
|
|
4014
|
+
export function helloHandler (request: Request, response: Response): void {
|
|
4015
|
+
const name = typeof request.query.name === 'string' ? request.query.name : 'world'
|
|
4016
|
+
response.send(greet(name))
|
|
4017
|
+
}
|
|
4018
|
+
`,
|
|
4019
|
+
"hello/index.ts": "export * from './greeting.contract'\nexport * from './greet.use-case'\nexport * from './hello.handler'\n",
|
|
4020
|
+
"main.ts": `import express from 'express'
|
|
4021
|
+
import { helloHandler } from './hello'
|
|
4022
|
+
|
|
4023
|
+
const host = process.env.HOST ?? 'localhost'
|
|
4024
|
+
const port = process.env.PORT ? Number(process.env.PORT) : 3000
|
|
4025
|
+
|
|
4026
|
+
const app = express()
|
|
4027
|
+
|
|
4028
|
+
app.get('/', helloHandler)
|
|
4029
|
+
|
|
4030
|
+
app.listen(port, host, () => {
|
|
4031
|
+
console.log('[ ready ] http://' + host + ':' + String(port))
|
|
4032
|
+
})
|
|
4033
|
+
`
|
|
4034
|
+
};
|
|
4035
|
+
}
|
|
4036
|
+
case "koa": {
|
|
4037
|
+
return {
|
|
4038
|
+
...SLICE,
|
|
4039
|
+
"hello/hello.handler.ts": `import type { Context } from 'koa'
|
|
4040
|
+
import { greet } from './greet.use-case'
|
|
4041
|
+
|
|
4042
|
+
export function helloHandler (context: Context): void {
|
|
4043
|
+
const name = typeof context.query.name === 'string' ? context.query.name : 'world'
|
|
4044
|
+
context.body = greet(name)
|
|
4045
|
+
}
|
|
4046
|
+
`,
|
|
4047
|
+
"hello/index.ts": "export * from './greeting.contract'\nexport * from './greet.use-case'\nexport * from './hello.handler'\n",
|
|
4048
|
+
"main.ts": `import Koa from 'koa'
|
|
4049
|
+
import { helloHandler } from './hello'
|
|
4050
|
+
|
|
4051
|
+
const host = process.env.HOST ?? 'localhost'
|
|
4052
|
+
const port = process.env.PORT ? Number(process.env.PORT) : 3000
|
|
4053
|
+
|
|
4054
|
+
const app = new Koa()
|
|
4055
|
+
|
|
4056
|
+
app.use(helloHandler)
|
|
4057
|
+
|
|
4058
|
+
app.listen(port, host, () => {
|
|
4059
|
+
console.log('[ ready ] http://' + host + ':' + String(port))
|
|
4060
|
+
})
|
|
4061
|
+
`
|
|
4062
|
+
};
|
|
4063
|
+
}
|
|
4064
|
+
case "fastify":
|
|
4065
|
+
case "nest": {
|
|
4066
|
+
return null;
|
|
4067
|
+
}
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
// src/project-scaffolding/node.use-case.ts
|
|
3973
4072
|
function ensurePlugin2(workspaceRoot, packageName) {
|
|
3974
4073
|
if (hasPlugin(workspaceRoot, packageName)) {
|
|
3975
4074
|
return;
|
|
@@ -4046,6 +4145,12 @@ function nodeAppPackageTarget(name) {
|
|
|
4046
4145
|
}
|
|
4047
4146
|
function addNodeApp(workspaceRoot, name, stack, framework = "none") {
|
|
4048
4147
|
runNodeApp(workspaceRoot, name, stack, framework);
|
|
4148
|
+
const example = nodeAppExampleFiles(framework);
|
|
4149
|
+
if (example !== null) {
|
|
4150
|
+
for (const [relative, contents] of Object.entries(example)) {
|
|
4151
|
+
writeFileEnsured((0, import_node_path12.join)(workspaceRoot, "apps", name, "src", relative), contents);
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4049
4154
|
ensureAdmZip(workspaceRoot);
|
|
4050
4155
|
addNxTargets((0, import_node_path12.join)(workspaceRoot, "apps", name, "package.json"), {
|
|
4051
4156
|
package: nodeAppPackageTarget(name)
|
|
@@ -4768,6 +4873,86 @@ async function addPythonVendor(workspaceRoot, consumer, options, kindProvided) {
|
|
|
4768
4873
|
// src/project-scaffolding/react-app.use-case.ts
|
|
4769
4874
|
var import_node_fs15 = require("fs");
|
|
4770
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
|
|
4771
4956
|
var REACT_ENVIRONMENTS = ["dev", "uat", "prod"];
|
|
4772
4957
|
function reactEnvironmentFile(environment) {
|
|
4773
4958
|
return `# Vite compiles VITE_-prefixed vars into the '${environment}' bundle at build time.
|
|
@@ -4843,6 +5028,11 @@ function addReactApp(workspaceRoot, name, stack) {
|
|
|
4843
5028
|
allowEnvFiles(workspaceRoot);
|
|
4844
5029
|
addNxTargets((0, import_node_path18.join)(reactAppRoot, "package.json"), reactAppTargets(name));
|
|
4845
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
|
+
}
|
|
4846
5036
|
removeGeneratedEslintConfig(workspaceRoot, `apps/${name}`);
|
|
4847
5037
|
registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:serve` });
|
|
4848
5038
|
}
|