Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename example to template #102

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["@webx-kit/app-*", "@webx-kit/docs", "@webx-kit/example-*", "@webx-kit/test-*", "!@webx-kit/test-utils"]
"ignore": ["@webx-kit/app-*", "@webx-kit/docs", "@webx-kit/template-*", "@webx-kit/test-*", "!@webx-kit/test-utils"]
}
5 changes: 5 additions & 0 deletions .changeset/fifty-gorillas-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-webx": patch
---

refactor: rename `example` to `template`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"engines": {
"node": ">=18.19.0"
},
"packageManager": "pnpm@9.12.3",
"packageManager": "pnpm@9.14.4",
"scripts": {
"lint:type": "nx run-many -t lint:type",
"build": "nx run-many -t build",
Expand Down
1 change: 1 addition & 0 deletions packages/core-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@webx-kit/core-plugin",
"version": "0.1.0",
"type": "commonjs",
"exports": {
"./background": {
"types": "./src/background.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-plugin/src/build-http/build-http-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const loader: Rspack.LoaderDefinition = function (_code, _sourceMap, _additional
.then(async (res) => {
const contentType = res.headers.get('content-type');
if (contentType && /^application\/json\b/.test(contentType)) {
return `export default JSON.parse(${JSON.stringify(JSON.stringify(await res.json()))})`;
return `module.exports = ${JSON.stringify(await res.json())}`;
}
return await res.text();
})
Expand Down
1 change: 1 addition & 0 deletions packages/create-webx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "create-webx",
"version": "0.1.0",
"type": "commonjs",
"bin": {
"create-webx": "./dist/index.js"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/create-webx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ async function main() {
const { stdout: lastCommitHash } = await execa('git', ['rev-parse', 'HEAD'], { cwd: repoDir });
debug({ lastCommitHash });

await fs.promises.cp(path.resolve(repoDir, 'examples', template), targetDir, { recursive: true });
await fs.promises.cp(path.resolve(repoDir, 'templates', template), targetDir, { recursive: true });
const resolvedPackageJson = await updateWorkspaceReferences(repoDir, path.resolve(targetDir, 'package.json'));
await fs.promises.writeFile(path.resolve(targetDir, 'package.json'), JSON.stringify(resolvedPackageJson, null, 2));

Expand Down
4 changes: 2 additions & 2 deletions packages/create-webx/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ assert(root);

test('ensure template exists', async () => {
for (const template of templateLists) {
expect(fs.existsSync(path.resolve(root, 'examples', template.value, 'package.json'))).toBeTruthy();
expect(fs.existsSync(path.resolve(root, 'templates', template.value, 'package.json'))).toBeTruthy();
}
});

test('updateWorkspaceReferences', async () => {
const packageJson = await updateWorkspaceReferences(root, path.resolve(root, 'examples/svelte/package.json'));
const packageJson = await updateWorkspaceReferences(root, path.resolve(root, 'templates/svelte/package.json'));
expect(JSON.stringify(packageJson)).not.toContain('workspace:');
});
1 change: 1 addition & 0 deletions packages/modernjs-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@webx-kit/modernjs-plugin",
"version": "0.1.0",
"type": "commonjs",
"exports": {
".": {
"types": "./src/index.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/rsbuild-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@webx-kit/rsbuild-plugin",
"version": "0.1.0",
"type": "commonjs",
"exports": {
".": {
"types": "./src/index.ts",
Expand Down
Loading