@cedarjs/cli 8.0.0-canary.3595 → 8.0.0-canary.3598

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.
@@ -1,3 +1,4 @@
1
+ import execa from "execa";
1
2
  const UPLOADS_GITIGNORE_ENTRY = "api/.uploads";
2
3
  function transformGitignore(source) {
3
4
  const activeLines = source.split("\n").map((line) => line.trimEnd()).filter((line) => line.length > 0 && !line.startsWith("#"));
@@ -11,7 +12,23 @@ ${UPLOADS_GITIGNORE_ENTRY}`);
11
12
  const prefix = source === "" || source.endsWith("\n") ? source : source + "\n";
12
13
  return prefix + UPLOADS_GITIGNORE_ENTRY + "\n";
13
14
  }
15
+ async function findIgnoredPaths(cwd, paths) {
16
+ if (paths.length === 0) {
17
+ return [];
18
+ }
19
+ try {
20
+ const { stdout } = await execa("git", ["check-ignore", "-z", "--stdin"], {
21
+ cwd,
22
+ input: paths.join("\0") + "\0",
23
+ reject: false
24
+ });
25
+ return stdout.split("\0").filter(Boolean);
26
+ } catch {
27
+ return [];
28
+ }
29
+ }
14
30
  export {
15
31
  UPLOADS_GITIGNORE_ENTRY,
32
+ findIgnoredPaths,
16
33
  transformGitignore
17
34
  };
@@ -18,7 +18,7 @@ import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
18
18
  import { isTypeScriptProject } from "../../../lib/project.js";
19
19
  import { generateSecret } from "../../generate/secret/secret.js";
20
20
  import { setupServerFileTasks } from "../server-file/serverFileHandler.js";
21
- import { transformGitignore } from "./gitignore.js";
21
+ import { findIgnoredPaths, transformGitignore } from "./gitignore.js";
22
22
  import { addUploadModel } from "./schemaPrisma.js";
23
23
  import {
24
24
  addUploadsPlugin,
@@ -102,6 +102,8 @@ const handler = async ({ targets, force }) => {
102
102
  const packageJson = await import(pathToFileURL(path.join(paths.base, "package.json")).href, { with: { type: "json" } });
103
103
  const cedarVersion = packageJson.default.devDependencies["@cedarjs/core"] ?? "latest";
104
104
  const serverFilePath = path.join(paths.api.src, `server.${ext}`);
105
+ const generatedFilePaths = [];
106
+ let ignoredFilesWarning;
105
107
  const writeTemplateFile = async (templateFile, outputPath, replacements = {}) => {
106
108
  const templatePath = path.resolve(
107
109
  import.meta.dirname,
@@ -113,6 +115,7 @@ const handler = async ({ targets, force }) => {
113
115
  templateContent = templateContent.replaceAll(token, value);
114
116
  }
115
117
  const content = projectIsTypescript ? templateContent : await transformTSToJS(outputPath, templateContent);
118
+ generatedFilePaths.push(outputPath);
116
119
  return writeFile(outputPath, content, { overwriteExisting: force });
117
120
  };
118
121
  const apiPackages = [`@cedarjs/uploads@${cedarVersion}`];
@@ -285,6 +288,24 @@ const handler = async ({ targets, force }) => {
285
288
  fs.writeFileSync(gitignorePath, updated, "utf-8");
286
289
  }
287
290
  },
291
+ {
292
+ title: "Checking the generated files are tracked by git...",
293
+ task: async () => {
294
+ const ignoredPaths = await findIgnoredPaths(paths.base, [
295
+ ...generatedFilePaths,
296
+ serverFilePath
297
+ ]);
298
+ if (ignoredPaths.length === 0) {
299
+ return;
300
+ }
301
+ const relativePaths = ignoredPaths.map((ignoredPath) => path.relative(paths.base, ignoredPath)).join("\n");
302
+ ignoredFilesWarning = `A .gitignore rule is hiding generated file(s) from git:
303
+
304
+ ${relativePaths}
305
+
306
+ This usually happens after migrating from @cedarjs/storage, which left behind an unanchored \`uploads\` or \`uploads/\` rule. Anchor it (e.g. \`/uploads/\`) or remove it, then make sure the file(s) above get committed.`;
307
+ }
308
+ },
288
309
  {
289
310
  title: "Prettifying changed files",
290
311
  task: async (_ctx, task) => {
@@ -349,6 +370,11 @@ const handler = async ({ targets, force }) => {
349
370
  );
350
371
  try {
351
372
  await tasks.run();
373
+ if (ignoredFilesWarning) {
374
+ console.warn(`
375
+ ${c.warning(ignoredFilesWarning)}
376
+ `);
377
+ }
352
378
  } catch (e) {
353
379
  const message = e instanceof Error ? e.message : String(e);
354
380
  const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "8.0.0-canary.3595",
3
+ "version": "8.0.0-canary.3598",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,17 +36,17 @@
36
36
  "@babel/preset-typescript": "7.29.7",
37
37
  "@babel/traverse": "7.29.12",
38
38
  "@babel/types": "7.29.11",
39
- "@cedarjs/api-server": "8.0.0-canary.3595",
40
- "@cedarjs/babel-config": "8.0.0-canary.3595",
41
- "@cedarjs/cli-helpers": "8.0.0-canary.3595",
42
- "@cedarjs/internal": "8.0.0-canary.3595",
43
- "@cedarjs/prerender": "8.0.0-canary.3595",
44
- "@cedarjs/project-config": "8.0.0-canary.3595",
45
- "@cedarjs/structure": "8.0.0-canary.3595",
46
- "@cedarjs/telemetry": "8.0.0-canary.3595",
47
- "@cedarjs/utils": "8.0.0-canary.3595",
48
- "@cedarjs/vite": "8.0.0-canary.3595",
49
- "@cedarjs/web-server": "8.0.0-canary.3595",
39
+ "@cedarjs/api-server": "8.0.0-canary.3598",
40
+ "@cedarjs/babel-config": "8.0.0-canary.3598",
41
+ "@cedarjs/cli-helpers": "8.0.0-canary.3598",
42
+ "@cedarjs/internal": "8.0.0-canary.3598",
43
+ "@cedarjs/prerender": "8.0.0-canary.3598",
44
+ "@cedarjs/project-config": "8.0.0-canary.3598",
45
+ "@cedarjs/structure": "8.0.0-canary.3598",
46
+ "@cedarjs/telemetry": "8.0.0-canary.3598",
47
+ "@cedarjs/utils": "8.0.0-canary.3598",
48
+ "@cedarjs/vite": "8.0.0-canary.3598",
49
+ "@cedarjs/web-server": "8.0.0-canary.3598",
50
50
  "@listr2/prompt-adapter-enquirer": "4.4.3",
51
51
  "@opentelemetry/api": "1.9.1",
52
52
  "@opentelemetry/core": "2.12.0",
@@ -93,7 +93,7 @@
93
93
  "yargs": "18.2.0"
94
94
  },
95
95
  "devDependencies": {
96
- "@cedarjs/framework-tools": "8.0.0-canary.3595",
96
+ "@cedarjs/framework-tools": "8.0.0-canary.3598",
97
97
  "@prisma/dmmf": "7.10.1",
98
98
  "@types/archiver": "^7.0.0",
99
99
  "memfs": "4.80.0",