@alauda/doom 0.19.2 → 0.19.4

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.
@@ -122,7 +122,6 @@ const limit = pRateLimit({
122
122
  concurrency: 10,
123
123
  });
124
124
  const supportedLanguages = SUPPORTED_LANGUAGES.join(', ');
125
- const shaHash = crypto.createHash('sha256');
126
125
  export const translateCommand = new Command('translate')
127
126
  .description('Translate the documentation')
128
127
  .argument('[root]', 'Root directory of the documentation')
@@ -201,7 +200,10 @@ export const translateCommand = new Command('translate')
201
200
  allSourceFilePaths.delete(sourceFilePath);
202
201
  return;
203
202
  }
204
- const sourceSHA = shaHash.update(sourceContent).digest('hex');
203
+ const sourceSHA = crypto
204
+ .createHash('sha256')
205
+ .update(sourceContent)
206
+ .digest('hex');
205
207
  const targetFilePath = sourceFilePath.replace(sourceDir, targetDir);
206
208
  let targetContent;
207
209
  let targetFrontmatter;
@@ -215,15 +217,17 @@ export const translateCommand = new Command('translate')
215
217
  }
216
218
  }
217
219
  await limit(async () => {
218
- const relativePath = path.relative(docsDir, sourceFilePath);
219
- logger.info(`Translating ${cyan(relativePath)}`);
220
+ const sourceRelativePath = path.relative(docsDir, sourceFilePath);
221
+ const targetRelativePath = path.relative(docsDir, targetFilePath);
222
+ logger.info(`Translating ${cyan(sourceRelativePath)} to ${cyan(targetRelativePath)}`);
220
223
  const isMdx = sourceFilePath.endsWith('.mdx');
221
224
  const processor = isMdx ? mdxProcessor : mdProcessor;
222
225
  const ast = processor.parse(escapeMarkdownHeadingIds(sourceContent));
226
+ const targetBase = path.dirname(targetFilePath);
223
227
  const normalizeImgSrcOptions = {
224
228
  localPublicBase: path.resolve(docsDir, 'public'),
225
229
  sourceBase: path.dirname(sourceFilePath),
226
- targetBase: path.dirname(targetFilePath),
230
+ targetBase,
227
231
  translating: { source, target, copy },
228
232
  };
229
233
  const normalizedSourceContent = processor.stringify({
@@ -246,9 +250,9 @@ export const translateCommand = new Command('translate')
246
250
  newFrontmatter.title = sourceFrontmatter.i18n.title[target];
247
251
  }
248
252
  targetContent = matter.stringify(content.startsWith('\n') ? content : '\n' + content, newFrontmatter);
249
- await fs.mkdir(path.dirname(targetFilePath), { recursive: true });
253
+ await fs.mkdir(targetBase, { recursive: true });
250
254
  await fs.writeFile(targetFilePath, targetContent);
251
- logger.info(`${cyan(relativePath)} translated`);
255
+ logger.info(`${cyan(sourceRelativePath)} translated to ${cyan(targetRelativePath)}`);
252
256
  allSourceFilePaths.delete(sourceFilePath);
253
257
  });
254
258
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "0.19.2",
3
+ "version": "0.19.4",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": "https://gitlab-ce.alauda.cn/idp/Doom.git",