@erudit-js/cli 3.0.0-dev.8 → 3.0.0-dev.9

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.
Files changed (2) hide show
  1. package/dist/index.mjs +24 -11
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import * as fs from 'node:fs/promises';
8
8
  import * as path from 'node:path';
9
9
  import { spawn } from 'node:child_process';
10
10
 
11
- const version = "3.0.0-dev.8";
11
+ const version = "3.0.0-dev.9";
12
12
 
13
13
  function resolvePath(path) {
14
14
  path = resolvePaths(path);
@@ -75,14 +75,22 @@ function logCommand(command) {
75
75
  console.log();
76
76
  }
77
77
 
78
- async function alias2Relative(rootDir) {
79
- rootDir = resolvePaths(rootDir);
80
- if (!existsSync(rootDir)) {
78
+ async function alias2Relative(baseDir, toReplaceDir) {
79
+ baseDir = resolvePaths(baseDir);
80
+ toReplaceDir = resolvePaths(toReplaceDir);
81
+ if (!existsSync(baseDir)) {
82
+ console.log(`Base directory ${baseDir} does not exist. Skipping...`);
81
83
  return;
82
84
  }
83
- const ALIASES_RESOLVED_FILE = path.join(rootDir, "ALIASES_RESOLVED");
85
+ if (!existsSync(toReplaceDir)) {
86
+ console.log(
87
+ `Target directory ${toReplaceDir} does not exist. Skipping...`
88
+ );
89
+ return;
90
+ }
91
+ const ALIASES_RESOLVED_FILE = path.join(toReplaceDir, "ALIASES_RESOLVED");
84
92
  if (existsSync(ALIASES_RESOLVED_FILE)) {
85
- console.log("Aliases already resolved. Skipping...");
93
+ console.log(`Aliases already resolved in ${toReplaceDir}. Skipping...`);
86
94
  return;
87
95
  }
88
96
  const replaceMap = {
@@ -92,12 +100,12 @@ async function alias2Relative(rootDir) {
92
100
  "@shared": "./shared",
93
101
  "@app": "./app"
94
102
  };
95
- const allFiles = await findAllFiles(rootDir);
103
+ const allFiles = await findAllFiles(toReplaceDir);
96
104
  for (const filePath of allFiles) {
97
- await processFile(filePath, rootDir, replaceMap);
105
+ await processFile(filePath, baseDir, replaceMap);
98
106
  }
99
107
  await fs.writeFile(ALIASES_RESOLVED_FILE, (/* @__PURE__ */ new Date()).toISOString());
100
- console.log("All aliases resolved successfully");
108
+ console.log(`All aliases in ${toReplaceDir} resolved successfully!`);
101
109
  }
102
110
  async function findAllFiles(dir) {
103
111
  const results = [];
@@ -179,8 +187,13 @@ async function processFile(filePath, rootDir, replaceMap) {
179
187
  async function prepare$1(projectPath, eruditPath) {
180
188
  const eruditBuildDir = `${projectPath}/.erudit`;
181
189
  const distDir = `${projectPath}/dist`;
182
- const nodeModulesErudit = `${projectPath}/node_modules/erudit`;
183
- await alias2Relative(nodeModulesErudit);
190
+ const nodeModules = `${projectPath}/node_modules`;
191
+ const nodeModulesErudit = `${nodeModules}/erudit`;
192
+ await alias2Relative(nodeModulesErudit, nodeModulesErudit);
193
+ await alias2Relative(
194
+ nodeModulesErudit,
195
+ nodeModules + "/@erudit-js/bitran-elements"
196
+ );
184
197
  consola.start("Cleaning up...");
185
198
  if (existsSync(distDir)) rmSync(distDir, { recursive: true });
186
199
  if (existsSync(eruditBuildDir)) rmSync(eruditBuildDir, { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erudit-js/cli",
3
- "version": "3.0.0-dev.8",
3
+ "version": "3.0.0-dev.9",
4
4
  "type": "module",
5
5
  "description": "📟 Command Line Interface for Erudit",
6
6
  "license": "MIT",
@@ -28,7 +28,7 @@
28
28
  "dist"
29
29
  ],
30
30
  "dependencies": {
31
- "@erudit-js/cog": "3.0.0-dev.8",
31
+ "@erudit-js/cog": "3.0.0-dev.9",
32
32
  "chalk": "^5.4.1",
33
33
  "citty": "^0.1.6",
34
34
  "consola": "^3.4.0"