prr-kit 2.0.2 → 2.0.3
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/package.json
CHANGED
|
@@ -63,6 +63,9 @@ class Installer {
|
|
|
63
63
|
await fs.ensureDir(path.join(outputFolderAbs, 'reviews'));
|
|
64
64
|
await prompts.log.info(' ✓ Output directories created');
|
|
65
65
|
|
|
66
|
+
// Update .gitignore
|
|
67
|
+
await this.updateGitignore(projectDir, config.outputFolder || '_prr-output');
|
|
68
|
+
|
|
66
69
|
// Generate manifests
|
|
67
70
|
const cfgDir = path.join(prrDir, '_config');
|
|
68
71
|
await fs.ensureDir(cfgDir);
|
|
@@ -135,6 +138,23 @@ class Installer {
|
|
|
135
138
|
}
|
|
136
139
|
}
|
|
137
140
|
|
|
141
|
+
async updateGitignore(projectDir, outputFolder) {
|
|
142
|
+
const gitignorePath = path.join(projectDir, '.gitignore');
|
|
143
|
+
const entries = [`${PRR_FOLDER_NAME}/`, `${outputFolder}/`];
|
|
144
|
+
|
|
145
|
+
if (!(await fs.pathExists(gitignorePath))) return;
|
|
146
|
+
|
|
147
|
+
const content = await fs.readFile(gitignorePath, 'utf8');
|
|
148
|
+
const lines = content.split('\n').map((l) => l.trim());
|
|
149
|
+
const toAdd = entries.filter((e) => !lines.includes(e) && !lines.includes(e.replace(/\/$/, '')));
|
|
150
|
+
|
|
151
|
+
if (toAdd.length === 0) return;
|
|
152
|
+
|
|
153
|
+
const separator = content.endsWith('\n') ? '' : '\n';
|
|
154
|
+
await fs.appendFile(gitignorePath, `${separator}${toAdd.join('\n')}\n`, 'utf8');
|
|
155
|
+
await prompts.log.info(` ✓ .gitignore updated (${toAdd.join(', ')})`);
|
|
156
|
+
}
|
|
157
|
+
|
|
138
158
|
async uninstall(projectDir) {
|
|
139
159
|
const prrDir = path.join(projectDir, PRR_FOLDER_NAME);
|
|
140
160
|
if (await fs.pathExists(prrDir)) {
|