@nshiab/setup-data-project 1.0.34 → 1.0.36

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.
@@ -3,7 +3,7 @@ import { join } from "node:path";
3
3
  import { log } from "@clack/prompts";
4
4
  export function createFolderStructure(selectedPackages) {
5
5
  const sdaFolder = "sda";
6
- const folders = ["data", "helpers", "output"];
6
+ const folders = ["data", "helpers", "output", "tests"];
7
7
  if (!existsSync(sdaFolder)) {
8
8
  mkdirSync(sdaFolder, { recursive: true });
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ensureAgents.d.ts","sourceRoot":"","sources":["../../src/helpers/ensureAgents.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,iBAAiB,GAAE,MAAM,EAA6B,QAyHvD"}
1
+ {"version":3,"file":"ensureAgents.d.ts","sourceRoot":"","sources":["../../src/helpers/ensureAgents.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,iBAAiB,GAAE,MAAM,EAA6B,QAgIvD"}
@@ -48,8 +48,17 @@ export function ensureAgents(docsMapping, runtime, installedPackages = Object.ke
48
48
  }
49
49
  }
50
50
  const configFile = runtime === "deno" ? "deno.json" : "package.json";
51
- const runSda = runtime === "deno" ? "deno task sda" : "npm run sda";
51
+ const runSdaOnce = runtime === "deno"
52
+ ? "deno run -A --env --check sda/main.ts"
53
+ : runtime === "bun"
54
+ ? "bun run sda/main.ts"
55
+ : "node --env-file-if-exists=.env --experimental-strip-types sda/main.ts";
52
56
  const runClean = runtime === "deno" ? "deno task clean" : "npm run clean";
57
+ const runAllTests = runtime === "deno"
58
+ ? "deno task all-tests"
59
+ : runtime === "bun"
60
+ ? "bun run all-tests"
61
+ : "npm run all-tests";
53
62
  const installedPackageConfigs = getInstalledPackageConfigs(installedPackages);
54
63
  const importExamples = installedPackageConfigs.map((pkg) => {
55
64
  const repoName = pkg.value.split("/")[1];
@@ -69,21 +78,21 @@ ${importExamples.join("\n")}
69
78
  }
70
79
  let content = `Always verify if there is a ${configFile} file in the root of the project and familiarize yourself with the scripts available in it and the libraries already installed in the project.
71
80
 
72
- Always use "sda" task when available (e.g. \`${runSda}\`).
81
+ Run \`sda/main.ts\` with \`${runSdaOnce}\`. Do not use the \`sda\` task for agent-driven checks because it runs in watch mode and will keep waiting for file changes.
73
82
 
74
- ${runtime === "deno"
75
- ? "Before handing off your work, run `deno lint` and `deno fmt` as well. Fix any errors or warnings triggered along the way."
76
- : "If it's a Node.js project, you can also run `node --env-file=.env --experimental-strip-types --no-warnings sda/main.ts` to test your code. Before handing off your work, always fix any errors or warnings triggered along the way."}
83
+ Before handing off your work, always run \`${runAllTests}\`, even if no tests have been added yet. Fix any errors or warnings it reports.
77
84
 
78
- Use the \`clean\` task (e.g. \`${runClean}\`) to remove the cache and other temporary files.
85
+ The \`clean\` task (e.g. \`${runClean}\`) removes caches and other temporary files. Do not run it routinely. Cached results can be especially valuable for computationally expensive operations or API calls. If you are unsure whether the caches should be removed, ask the user first.
79
86
 
80
87
  Always use "sda/main.ts" as the entry point.
81
88
 
82
89
  If you need to create other TypeScript files, create them in the "sda/helpers" folder. Prioritize the use of helper functions to keep the code well organized and maintainable, with one helper function per file, with the file named after the function. Prioritize default exports for helper functions.
83
90
 
84
- If you need to download data, always put the files in the "sda/data" folder, which is gitignored.
91
+ Put tests in the "sda/tests" folder. Write focused tests for reusable helpers and important data transformations when appropriate.
85
92
 
86
- If you need to output data to a file, always put the file in the "sda/output" folder.
93
+ If you need to download data, always put the files in the "sda/data" folder, which is ignored by Git.
94
+
95
+ If you need to output data to a file, always put the file in the "sda/output" folder, which is also ignored by Git.
87
96
  ${libraryGuidance}`;
88
97
  if (journalismFunctions !== "") {
89
98
  content += `
@@ -35,8 +35,8 @@ Here's the recommended workflow:
35
35
 
36
36
  - Put your raw data in the \`sda/data\` folder. Note that this folder is
37
37
  ignored by Git.
38
- - Use the \`sda/main.ts\` file to clean and process your raw data. Write the
39
- results to the \`sda/output\` folder.
38
+ - Use the \`sda/main.ts\` file to process your raw data. Write the
39
+ results to the \`sda/output\` folder, which is also ignored by Git.
40
40
 
41
41
  When working on your project, use the following command:
42
42
 
@@ -1,5 +1,6 @@
1
1
  export declare function getProjectTasks(): {
2
2
  sda: string;
3
+ "all-tests": string;
3
4
  clean: string;
4
5
  };
5
6
  //# sourceMappingURL=getProjectTasks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getProjectTasks.d.ts","sourceRoot":"","sources":["../../src/helpers/getProjectTasks.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe;;;EAW9B"}
1
+ {"version":3,"file":"getProjectTasks.d.ts","sourceRoot":"","sources":["../../src/helpers/getProjectTasks.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe;;;;EAgB9B"}
@@ -7,6 +7,11 @@ export function getProjectTasks() {
7
7
  : runtime === "bun"
8
8
  ? "bun run --watch sda/main.ts"
9
9
  : "node --env-file-if-exists=.env --watch --experimental-strip-types sda/main.ts",
10
+ "all-tests": runtime === "deno"
11
+ ? "deno fmt --check && deno lint && deno check sda/main.ts && deno test -A"
12
+ : runtime === "bun"
13
+ ? "bun test --pass-with-no-tests"
14
+ : "node --env-file-if-exists=.env --experimental-strip-types --test",
10
15
  clean: "rm -rf .sda-cache .journalism-cache .tmp",
11
16
  };
12
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nshiab/setup-data-project",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "Quickly kick off your data project using the simple-data-analysis and journalism libraries.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -6,7 +6,7 @@ const node_path_1 = require("node:path");
6
6
  const prompts_1 = require("@clack/prompts");
7
7
  function createFolderStructure(selectedPackages) {
8
8
  const sdaFolder = "sda";
9
- const folders = ["data", "helpers", "output"];
9
+ const folders = ["data", "helpers", "output", "tests"];
10
10
  if (!(0, node_fs_1.existsSync)(sdaFolder)) {
11
11
  (0, node_fs_1.mkdirSync)(sdaFolder, { recursive: true });
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ensureAgents.d.ts","sourceRoot":"","sources":["../../src/helpers/ensureAgents.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,iBAAiB,GAAE,MAAM,EAA6B,QAyHvD"}
1
+ {"version":3,"file":"ensureAgents.d.ts","sourceRoot":"","sources":["../../src/helpers/ensureAgents.ts"],"names":[],"mappings":"AAOA,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,OAAO,EAAE,MAAM,EACf,iBAAiB,GAAE,MAAM,EAA6B,QAgIvD"}
@@ -51,8 +51,17 @@ function ensureAgents(docsMapping, runtime, installedPackages = Object.keys(docs
51
51
  }
52
52
  }
53
53
  const configFile = runtime === "deno" ? "deno.json" : "package.json";
54
- const runSda = runtime === "deno" ? "deno task sda" : "npm run sda";
54
+ const runSdaOnce = runtime === "deno"
55
+ ? "deno run -A --env --check sda/main.ts"
56
+ : runtime === "bun"
57
+ ? "bun run sda/main.ts"
58
+ : "node --env-file-if-exists=.env --experimental-strip-types sda/main.ts";
55
59
  const runClean = runtime === "deno" ? "deno task clean" : "npm run clean";
60
+ const runAllTests = runtime === "deno"
61
+ ? "deno task all-tests"
62
+ : runtime === "bun"
63
+ ? "bun run all-tests"
64
+ : "npm run all-tests";
56
65
  const installedPackageConfigs = (0, packageRegistry_js_1.getInstalledPackageConfigs)(installedPackages);
57
66
  const importExamples = installedPackageConfigs.map((pkg) => {
58
67
  const repoName = pkg.value.split("/")[1];
@@ -72,21 +81,21 @@ ${importExamples.join("\n")}
72
81
  }
73
82
  let content = `Always verify if there is a ${configFile} file in the root of the project and familiarize yourself with the scripts available in it and the libraries already installed in the project.
74
83
 
75
- Always use "sda" task when available (e.g. \`${runSda}\`).
84
+ Run \`sda/main.ts\` with \`${runSdaOnce}\`. Do not use the \`sda\` task for agent-driven checks because it runs in watch mode and will keep waiting for file changes.
76
85
 
77
- ${runtime === "deno"
78
- ? "Before handing off your work, run `deno lint` and `deno fmt` as well. Fix any errors or warnings triggered along the way."
79
- : "If it's a Node.js project, you can also run `node --env-file=.env --experimental-strip-types --no-warnings sda/main.ts` to test your code. Before handing off your work, always fix any errors or warnings triggered along the way."}
86
+ Before handing off your work, always run \`${runAllTests}\`, even if no tests have been added yet. Fix any errors or warnings it reports.
80
87
 
81
- Use the \`clean\` task (e.g. \`${runClean}\`) to remove the cache and other temporary files.
88
+ The \`clean\` task (e.g. \`${runClean}\`) removes caches and other temporary files. Do not run it routinely. Cached results can be especially valuable for computationally expensive operations or API calls. If you are unsure whether the caches should be removed, ask the user first.
82
89
 
83
90
  Always use "sda/main.ts" as the entry point.
84
91
 
85
92
  If you need to create other TypeScript files, create them in the "sda/helpers" folder. Prioritize the use of helper functions to keep the code well organized and maintainable, with one helper function per file, with the file named after the function. Prioritize default exports for helper functions.
86
93
 
87
- If you need to download data, always put the files in the "sda/data" folder, which is gitignored.
94
+ Put tests in the "sda/tests" folder. Write focused tests for reusable helpers and important data transformations when appropriate.
88
95
 
89
- If you need to output data to a file, always put the file in the "sda/output" folder.
96
+ If you need to download data, always put the files in the "sda/data" folder, which is ignored by Git.
97
+
98
+ If you need to output data to a file, always put the file in the "sda/output" folder, which is also ignored by Git.
90
99
  ${libraryGuidance}`;
91
100
  if (journalismFunctions !== "") {
92
101
  content += `
@@ -38,8 +38,8 @@ Here's the recommended workflow:
38
38
 
39
39
  - Put your raw data in the \`sda/data\` folder. Note that this folder is
40
40
  ignored by Git.
41
- - Use the \`sda/main.ts\` file to clean and process your raw data. Write the
42
- results to the \`sda/output\` folder.
41
+ - Use the \`sda/main.ts\` file to process your raw data. Write the
42
+ results to the \`sda/output\` folder, which is also ignored by Git.
43
43
 
44
44
  When working on your project, use the following command:
45
45
 
@@ -1,5 +1,6 @@
1
1
  export declare function getProjectTasks(): {
2
2
  sda: string;
3
+ "all-tests": string;
3
4
  clean: string;
4
5
  };
5
6
  //# sourceMappingURL=getProjectTasks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getProjectTasks.d.ts","sourceRoot":"","sources":["../../src/helpers/getProjectTasks.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe;;;EAW9B"}
1
+ {"version":3,"file":"getProjectTasks.d.ts","sourceRoot":"","sources":["../../src/helpers/getProjectTasks.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe;;;;EAgB9B"}
@@ -10,6 +10,11 @@ function getProjectTasks() {
10
10
  : runtime === "bun"
11
11
  ? "bun run --watch sda/main.ts"
12
12
  : "node --env-file-if-exists=.env --watch --experimental-strip-types sda/main.ts",
13
+ "all-tests": runtime === "deno"
14
+ ? "deno fmt --check && deno lint && deno check sda/main.ts && deno test -A"
15
+ : runtime === "bun"
16
+ ? "bun test --pass-with-no-tests"
17
+ : "node --env-file-if-exists=.env --experimental-strip-types --test",
13
18
  clean: "rm -rf .sda-cache .journalism-cache .tmp",
14
19
  };
15
20
  }