-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vue: migrate microfrontend to rsbuild
- Loading branch information
Showing
18 changed files
with
460 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
generators/javascript/generators/rsbuild/__snapshots__/generator.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`generator - javascript:rsbuild with defaults options should call source snapshot 1`] = `{}`; | ||
|
||
exports[`generator - javascript:rsbuild with defaults options should match files snapshot 1`] = ` | ||
{ | ||
".yo-rc.json": { | ||
"stateCleared": "modified", | ||
}, | ||
"package.json": { | ||
"stateCleared": "modified", | ||
}, | ||
"rsbuild.config.ts.jhi": { | ||
"stateCleared": "modified", | ||
}, | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright 2013-2024 the original author or authors from the JHipster project. | ||
* | ||
* This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
* for more information. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import type { JHipsterCommandDefinition } from '../../../../lib/command/types.js'; | ||
|
||
const command = { | ||
configs: {}, | ||
import: [], | ||
} as const satisfies JHipsterCommandDefinition; | ||
|
||
export default command; |
53 changes: 53 additions & 0 deletions
53
generators/javascript/generators/rsbuild/generator.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Copyright 2013-2024 the original author or authors from the JHipster project. | ||
* | ||
* This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
* for more information. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { basename, dirname, resolve } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { before, describe, expect, it } from 'esmocha'; | ||
|
||
import { shouldSupportFeatures, testBlueprintSupport } from '../../../../test/support/tests.js'; | ||
import { defaultHelpers as helpers, result } from '../../../../lib/testing/index.js'; | ||
import Generator from './index.js'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
const generator = `${basename(resolve(__dirname, '../../'))}:${basename(__dirname)}`; | ||
|
||
describe(`generator - ${generator}`, () => { | ||
shouldSupportFeatures(Generator); | ||
describe('blueprint support', () => testBlueprintSupport(generator)); | ||
|
||
describe('with defaults options', () => { | ||
before(async () => { | ||
await helpers.runJHipster(generator).withMockedJHipsterGenerators().withMockedSource().withSharedApplication({}).withJHipsterConfig(); | ||
}); | ||
|
||
it('should match files snapshot', () => { | ||
expect(result.getStateSnapshot()).toMatchSnapshot(); | ||
}); | ||
|
||
it('should call source snapshot', () => { | ||
expect(result.sourceCallsArg).toMatchSnapshot(); | ||
}); | ||
|
||
it('should compose with generators', () => { | ||
expect(result.composedMockedGenerators).toMatchInlineSnapshot(`[]`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/** | ||
* Copyright 2013-2024 the original author or authors from the JHipster project. | ||
* | ||
* This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
* for more information. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import BaseGenerator from '../../../../generators/base-application/index.js'; | ||
|
||
export default class RspackGenerator extends BaseGenerator { | ||
constructor(args, options, features) { | ||
super(args, options, { queueCommandTasks: true, ...features }); | ||
} | ||
|
||
async beforeQueue() { | ||
if (!this.fromBlueprint) { | ||
await this.composeWithBlueprints(); | ||
} | ||
|
||
if (!this.delegateToBlueprint) { | ||
await this.dependsOnBootstrapApplication(); | ||
} | ||
} | ||
|
||
get preparing() { | ||
return this.asPreparingTaskGroup({}); | ||
} | ||
|
||
get [BaseGenerator.PREPARING]() { | ||
return this.delegateTasksToBlueprint(() => this.preparing); | ||
} | ||
|
||
get postPreparing() { | ||
return this.asPostPreparingTaskGroup({}); | ||
} | ||
|
||
get [BaseGenerator.POST_PREPARING]() { | ||
return this.delegateTasksToBlueprint(() => this.postPreparing); | ||
} | ||
|
||
get preparingEachEntity() { | ||
return this.asPreparingEachEntityTaskGroup({}); | ||
} | ||
|
||
get [BaseGenerator.PREPARING_EACH_ENTITY]() { | ||
return this.delegateTasksToBlueprint(() => this.preparingEachEntity); | ||
} | ||
|
||
get preparingEachEntityField() { | ||
return this.asPreparingEachEntityFieldTaskGroup({}); | ||
} | ||
|
||
get [BaseGenerator.PREPARING_EACH_ENTITY_FIELD]() { | ||
return this.delegateTasksToBlueprint(() => this.preparingEachEntityField); | ||
} | ||
|
||
get preparingEachEntityRelationship() { | ||
return this.asPreparingEachEntityRelationshipTaskGroup({}); | ||
} | ||
|
||
get [BaseGenerator.PREPARING_EACH_ENTITY_RELATIONSHIP]() { | ||
return this.delegateTasksToBlueprint(() => this.preparingEachEntityRelationship); | ||
} | ||
|
||
get postPreparingEachEntity() { | ||
return this.asPostPreparingEachEntityTaskGroup({}); | ||
} | ||
|
||
get [BaseGenerator.POST_PREPARING_EACH_ENTITY]() { | ||
return this.delegateTasksToBlueprint(() => this.postPreparingEachEntity); | ||
} | ||
|
||
get default() { | ||
return this.asDefaultTaskGroup({}); | ||
} | ||
|
||
get [BaseGenerator.DEFAULT]() { | ||
return this.delegateTasksToBlueprint(() => this.default); | ||
} | ||
|
||
get writing() { | ||
return this.asWritingTaskGroup({ | ||
async writeFiles({ application }) { | ||
await this.writeFiles({ | ||
blocks: [{ templates: ['rsbuild.config.ts.jhi'] }], | ||
context: application, | ||
}); | ||
}, | ||
}); | ||
} | ||
|
||
get [BaseGenerator.WRITING]() { | ||
return this.delegateTasksToBlueprint(() => this.writing); | ||
} | ||
|
||
get postWriting() { | ||
return this.asPostWritingTaskGroup({ | ||
addScripts({ application }) { | ||
const { clientPackageManager } = application; | ||
this.packageJson.merge({ | ||
devDependencies: { | ||
'@rsbuild/core': 'latest', | ||
}, | ||
scripts: { | ||
start: 'rsbuild dev', | ||
build: 'rsbuild build', | ||
'webapp:build:dev': `${clientPackageManager} run build -- --mode=development`, | ||
'webapp:build:prod': `${clientPackageManager} run build -- --mode=production`, | ||
'webapp:dev': `${clientPackageManager} run start`, | ||
'webapp:serve': `${clientPackageManager} start`, | ||
}, | ||
}); | ||
}, | ||
}); | ||
} | ||
|
||
get [BaseGenerator.POST_WRITING]() { | ||
return this.delegateTasksToBlueprint(() => this.postWriting); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright 2013-2024 the original author or authors from the JHipster project. | ||
* | ||
* This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
* for more information. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export { default } from './generator.js'; | ||
export { default as command } from './command.js'; |
57 changes: 57 additions & 0 deletions
57
generators/javascript/generators/rsbuild/templates/rsbuild.config.ts.jhi.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<%# | ||
Copyright 2013-2024 the original author or authors from the JHipster project. | ||
This file is part of the JHipster project, see https://www.jhipster.tech/ | ||
for more information. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
-%> | ||
<&_ | ||
// Register sections and max allowed fragments, 0 for unlimited. | ||
fragments.registerSections({ | ||
importsSection: 0, | ||
pluginsSection: 0, | ||
configSection: 0, | ||
}); | ||
_&> | ||
import path from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { defineConfig } from '@rsbuild/core'; | ||
<&- fragments.importsSection() -&> | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
export default defineConfig({ | ||
root: path.join(__dirname, '<%- this.relativeDir(clientRootDir, clientSrcDir) %>'), | ||
output: { | ||
cleanDistPath: true, | ||
distPath: { | ||
root: path.join(__dirname, './<%= this.relativeDir(clientRootDir, clientDistDir) %>'), | ||
}, | ||
}, | ||
html: { | ||
template: './index.html', | ||
scriptLoading: 'defer', | ||
tags: [ | ||
{ | ||
tag: 'base', | ||
attrs: { href: '/' }, | ||
}, | ||
], | ||
}, | ||
plugins: [ | ||
<&- fragments.pluginsSection() -&> | ||
], | ||
<&- fragments.configSection() -&> | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.