@alauda/doom 0.5.2 → 0.5.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/lib/cli/new.js +21 -1
- package/package.json +2 -2
package/lib/cli/new.js
CHANGED
|
@@ -57,6 +57,7 @@ const resolveScaffoldings = async (name, force) => {
|
|
|
57
57
|
}
|
|
58
58
|
const git = simpleGit(repoFolder);
|
|
59
59
|
if (!created) {
|
|
60
|
+
logger.info(`Cloning scaffolding template \`${cyan(name)}\` repository...`);
|
|
60
61
|
await git.clone(/^((\w+):)?\/\//.test(repo)
|
|
61
62
|
? repo
|
|
62
63
|
: `https://gitlab-ce.alauda.cn/${repo}`, repoFolder, ['--depth', '1']);
|
|
@@ -77,9 +78,11 @@ const resolveScaffoldings = async (name, force) => {
|
|
|
77
78
|
const options = ['--depth', '1', '--force'];
|
|
78
79
|
for (const branch of branches) {
|
|
79
80
|
if (branch === currentBranch) {
|
|
80
|
-
|
|
81
|
+
logger.info(`Pulling latest changes from branch \`${cyan(branch)}\`...`);
|
|
82
|
+
await git.pull([...options, '--rebase']);
|
|
81
83
|
}
|
|
82
84
|
else {
|
|
85
|
+
logger.info(`Switching to branch \`${cyan(branch)}\`...`);
|
|
83
86
|
await git.fetch('origin', `${branch}:${branch}`, options);
|
|
84
87
|
await git.checkout((currentBranch = branch));
|
|
85
88
|
}
|
|
@@ -117,6 +120,7 @@ program
|
|
|
117
120
|
}
|
|
118
121
|
const { base, scaffoldings } = (await resolveScaffoldings(name, force)) || {};
|
|
119
122
|
if (!scaffoldings) {
|
|
123
|
+
logger.error(`Unable to resolve any scaffoldings, if you are sure the template \`${magenta(name)}\` exists, try to use the \`--force\` option, or event remove the local cache at ${magenta(path.resolve(scaffoldingsFolder, name))} and try again`);
|
|
120
124
|
return;
|
|
121
125
|
}
|
|
122
126
|
if (!type) {
|
|
@@ -139,6 +143,7 @@ program
|
|
|
139
143
|
for (const param of scaffolding.parameters || []) {
|
|
140
144
|
parameters[param.name] = await prompts[param.type](param.options);
|
|
141
145
|
}
|
|
146
|
+
logger.start('Generating scaffolding...');
|
|
142
147
|
for (const layout of scaffolding.layout || []) {
|
|
143
148
|
const source = path.resolve(base, render(layout.source, { parameters }));
|
|
144
149
|
const target = path.resolve(render(layout.target, { parameters }));
|
|
@@ -158,9 +163,17 @@ program
|
|
|
158
163
|
break;
|
|
159
164
|
}
|
|
160
165
|
case 'folder': {
|
|
166
|
+
const dirents = await fs.readdir(source, {
|
|
167
|
+
recursive: true,
|
|
168
|
+
withFileTypes: true,
|
|
169
|
+
});
|
|
170
|
+
const files = new Set(dirents
|
|
171
|
+
.filter((d) => d.isFile())
|
|
172
|
+
.map((d) => path.relative(source, path.resolve(d.parentPath, d.name))));
|
|
161
173
|
for (const matcher of layout.matchers || []) {
|
|
162
174
|
const matched = await glob(matcher.match.map((m) => render(m, { parameters })), { cwd: source });
|
|
163
175
|
for (const file of matched) {
|
|
176
|
+
files.delete(file);
|
|
164
177
|
await handleTemplateFile({
|
|
165
178
|
source: path.resolve(source, file),
|
|
166
179
|
target: path.resolve(target, file.endsWith('.ejs') ? file.slice(0, -4) : file),
|
|
@@ -170,10 +183,17 @@ program
|
|
|
170
183
|
});
|
|
171
184
|
}
|
|
172
185
|
}
|
|
186
|
+
for (const file of files) {
|
|
187
|
+
await handleTemplateFile({
|
|
188
|
+
source: path.resolve(source, file),
|
|
189
|
+
target: path.resolve(target, file),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
173
192
|
break;
|
|
174
193
|
}
|
|
175
194
|
}
|
|
176
195
|
}
|
|
196
|
+
logger.success('Scaffolding generated successfully!');
|
|
177
197
|
})
|
|
178
198
|
.parseAsync(process.argv)
|
|
179
199
|
.catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alauda/doom",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Doctor Doom making docs.",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"packageManager": "yarn@4.5.0",
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": ">=18.
|
|
12
|
+
"node": ">=18.20.0 <20 || >=20.1.0"
|
|
13
13
|
},
|
|
14
14
|
"bin": "lib/cli/index.js",
|
|
15
15
|
"exports": {
|