Skip to content
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
3 changes: 2 additions & 1 deletion .c8rc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"all": true,
"clean": false,
"clean": true,
"root": ".",
"include": ["packages/*/src/**/*.ts"],
"exclude": ["packages/*/src/**/types.ts"],
"reporter": ["text", "html", "lcov"],
"exclude-after-remap": true
}
6 changes: 5 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ jobs:
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

smoketests:
name: Smoketests
Expand Down Expand Up @@ -131,3 +130,8 @@ jobs:

- name: Run smoketests
run: npm run test:smoketests

- name: Upload coverage to Codecov
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# Node dependencies
node_modules
test/**/node_modules
!test/external-command/node_modules

# Lock files
yarn.lock
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"./packages/*"
],
"scripts": {
"clean": "del-cli \"*.tsbuildinfo\" \"packages/**/*.tsbuildinfo\" \"packages/*/lib/!(*.tpl)\" \"**/.yo-rc.json\"",
"clean": "del-cli \"*.tsbuildinfo\" \"packages/**/*.tsbuildinfo\" \"packages/*/lib/!(*.tpl)\"",
"prebuild": "npm run clean",
"prebuild:ci": "npm run clean && node ./scripts/setup-build.js",
"build": "tsc --build",
Expand All @@ -38,8 +38,8 @@
"fix:code": "npm run lint:code -- --fix",
"pretest": "npm run build && npm run lint",
"test": "npm run test:base",
"test:base": "node --experimental-vm-modules --enable-source-maps ./node_modules/jest-cli/bin/jest",
"test:smoketests": "c8 node smoketests",
"test:base": "node --experimental-vm-modules --enable-source-maps ./node_modules/jest-cli/bin/jest --workerThreads",
"test:smoketests": "c8 node --enable-source-maps smoketests/index.js",
"test:coverage": "c8 npm run test:base",
"update:docs": "node ./scripts/update-docs",
"version": "node ./node_modules/.bin/changeset version && node ./scripts/sync-changelogs.js",
Expand Down
22 changes: 13 additions & 9 deletions packages/create-webpack-app/src/utils/generate-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@ async function checkAndPrepareContent(config: AddConfig, isTemplate: boolean): P
return { status: "identical", content: existingFileContent };
}

// Prompt for conflict resolution
const tempFilePath = path.join("/tmp", `temp_${path.basename(config.path)}`);
await fs.writeFile(tempFilePath, newContent || "");

let userChoice: Result | undefined;
while (!userChoice) {
const action = await expand({
Expand Down Expand Up @@ -194,7 +190,14 @@ async function checkAndPrepareContent(config: AddConfig, isTemplate: boolean): P
case "overwrite_all":
globalConfig.overwriteAll = true;
return { status: "overwrite", content: newContent };
case "diff":
case "diff": {
// Prompt for conflict resolution
const tempFilePath = path.join(
config.data!.projectPath as string,
`.temp_${path.basename(config.path)}`,
);
await fs.writeFile(tempFilePath, newContent || "");

if (!isTemplate && Buffer.isBuffer(existingFileContent)) {
const existingStats = await fs.stat(config.path);
const newStats = await fs.stat(tempFilePath);
Expand All @@ -219,17 +222,18 @@ async function checkAndPrepareContent(config: AddConfig, isTemplate: boolean): P
} else {
await getDiff(config.path, tempFilePath);
}

await fs.unlink(tempFilePath).catch(() => {
logger.warn(`Failed to delete temporary file: ${tempFilePath}`);
});
break;
}
case "abort":
logger.error("Aborting process...");
process.exit(1);
}
}

await fs.unlink(tempFilePath).catch(() => {
logger.warn(`Failed to delete temporary file: ${tempFilePath}`);
});

return userChoice;
}
// If the file doesn't exist, create it
Expand Down
8 changes: 1 addition & 7 deletions packages/create-webpack-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
{
"extends": "../../tsconfig.json",
"exclude": ["src/utils/__tests__"],
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": ["./src"],
"references": [
{
"path": "../webpack-cli"
}
]
"include": ["./src"]
}
Loading
Loading