@nshiab/setup-data-project 1.0.24 → 1.0.26

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 +1 @@
1
- {"version":3,"file":"createFolderStructure.d.ts","sourceRoot":"","sources":["../../src/helpers/createFolderStructure.ts"],"names":[],"mappings":"AAKA,wBAAsB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,mBA4CrE"}
1
+ {"version":3,"file":"createFolderStructure.d.ts","sourceRoot":"","sources":["../../src/helpers/createFolderStructure.ts"],"names":[],"mappings":"AAKA,wBAAsB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,mBA8CrE"}
@@ -29,6 +29,8 @@ const table = sdb.newTable();
29
29
  // Do your magic here!
30
30
  // await table.loadData("./sda/data/...");
31
31
 
32
+ await table.logTable();
33
+
32
34
  await sdb.done();
33
35
  `;
34
36
  }
@@ -6,7 +6,7 @@ export function getProjectTasks() {
6
6
  ? "deno run -A --env --watch sda/main.ts"
7
7
  : runtime === "bun"
8
8
  ? "bun run --watch sda/main.ts"
9
- : "node --env-file=.env --watch sda/main.ts",
9
+ : "node --env-file=.env --watch --experimental-strip-types sda/main.ts",
10
10
  clean: "rm -rf .sda-cache .journalism-cache .tmp",
11
11
  };
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"installPackagesAndFetchDocs.d.ts","sourceRoot":"","sources":["../../src/helpers/installPackagesAndFetchDocs.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa;;CAEzB,CAAC;AAEF,wBAAsB,2BAA2B,CAC/C,gBAAgB,EAAE,MAAM,EAAE,EAC1B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmExB"}
1
+ {"version":3,"file":"installPackagesAndFetchDocs.d.ts","sourceRoot":"","sources":["../../src/helpers/installPackagesAndFetchDocs.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa;;CAEzB,CAAC;AAEF,wBAAsB,2BAA2B,CAC/C,gBAAgB,EAAE,MAAM,EAAE,EAC1B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA4FxB"}
@@ -15,54 +15,76 @@ export async function installPackagesAndFetchDocs(selectedPackages, options = {}
15
15
  let lastDoc = "";
16
16
  for (const pkg of selectedPackages) {
17
17
  const s = spinner();
18
- const installCmd = runtime === "deno"
19
- ? `deno add jsr:${pkg}`
20
- : runtime === "bun"
21
- ? `bun add ${pkg}`
22
- : `npm install ${pkg}`;
23
- if (!options.silent) {
24
- s.start(`Installing ${pkg} via ${runtime}...`);
18
+ const pkgsToInstall = [pkg];
19
+ if (pkg === "@nshiab/simple-data-analysis" ||
20
+ pkg === "@nshiab/journalism-dataviz") {
21
+ pkgsToInstall.push("@observablehq/plot");
25
22
  }
26
- try {
27
- await new Promise((resolve, reject) => {
28
- commandRunner.exec(installCmd, (error) => {
29
- if (error) {
30
- reject(error);
31
- }
32
- else {
33
- resolve(void 0);
34
- }
35
- });
36
- });
23
+ for (const p of pkgsToInstall) {
24
+ const isObservablePlot = p === "@observablehq/plot";
25
+ const installCmd = runtime === "deno"
26
+ ? (isObservablePlot ? "deno add npm:" + p : "deno add jsr:" + p)
27
+ : runtime === "bun"
28
+ ? "bun add " + p
29
+ : "npm install " + p;
37
30
  if (!options.silent) {
38
- s.stop(`✅ ${pkg} installed!`);
31
+ s.start("Installing " + p + " via " + runtime + "...");
32
+ }
33
+ try {
34
+ await new Promise((resolve, reject) => {
35
+ commandRunner.exec(installCmd, (error) => {
36
+ if (error) {
37
+ reject(error);
38
+ }
39
+ else {
40
+ resolve(void 0);
41
+ }
42
+ });
43
+ });
44
+ if (!options.silent) {
45
+ s.stop("✅ " + p + " installed!");
46
+ }
39
47
  }
40
- const sFetch = spinner();
48
+ catch (error) {
49
+ if (!options.silent) {
50
+ s.stop("❌ Failed to install " + p + ".");
51
+ }
52
+ throw error;
53
+ }
54
+ }
55
+ // Documentation logic
56
+ if (pkg === "@observablehq/plot") {
57
+ continue;
58
+ }
59
+ const sFetch = spinner();
60
+ try {
41
61
  if (!options.silent) {
42
- sFetch.start(`Fetching documentation for ${pkg}...`);
62
+ sFetch.start("Fetching documentation for " + pkg + "...");
43
63
  }
44
64
  const repoName = pkg.split("/")[1];
45
- const url = `https://raw.githubusercontent.com/nshiab/${repoName}/refs/heads/main/llm.md`;
65
+ const url = "https://raw.githubusercontent.com/nshiab/" + repoName +
66
+ "/refs/heads/main/llm.md";
46
67
  const response = await fetch(url);
47
68
  if (response.ok) {
48
69
  const docContent = await response.text();
49
- writeFileSync(join("docs", `${repoName}.md`), docContent);
70
+ writeFileSync(join("docs", repoName + ".md"), docContent);
50
71
  if (!options.silent) {
51
- sFetch.stop(`✅ Documentation for ${pkg} saved!`);
72
+ sFetch.stop("✅ Documentation for " + pkg + " saved!");
52
73
  }
53
74
  lastDoc = docContent;
54
75
  }
55
76
  else {
56
77
  if (!options.silent) {
57
- sFetch.stop(`⚠️ No documentation (llm.md) found for ${pkg}. Skipping doc fetch.`);
78
+ sFetch.stop("⚠️ No documentation (llm.md) found for " + pkg +
79
+ ". Skipping doc fetch.");
58
80
  }
59
81
  }
60
82
  }
61
83
  catch (error) {
62
84
  if (!options.silent) {
63
- s.stop(`❌ Failed to install ${pkg}.`);
85
+ sFetch.stop("❌ Failed to fetch documentation for " + pkg + ".");
64
86
  }
65
- throw error;
87
+ console.error(error);
66
88
  }
67
89
  }
68
90
  return lastDoc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nshiab/setup-data-project",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "Quickly kick off your data project using the simple-data-analysis and journalism libraries.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +1 @@
1
- {"version":3,"file":"createFolderStructure.d.ts","sourceRoot":"","sources":["../../src/helpers/createFolderStructure.ts"],"names":[],"mappings":"AAKA,wBAAsB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,mBA4CrE"}
1
+ {"version":3,"file":"createFolderStructure.d.ts","sourceRoot":"","sources":["../../src/helpers/createFolderStructure.ts"],"names":[],"mappings":"AAKA,wBAAsB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,mBA8CrE"}
@@ -32,6 +32,8 @@ const table = sdb.newTable();
32
32
  // Do your magic here!
33
33
  // await table.loadData("./sda/data/...");
34
34
 
35
+ await table.logTable();
36
+
35
37
  await sdb.done();
36
38
  `;
37
39
  }
@@ -9,7 +9,7 @@ function getProjectTasks() {
9
9
  ? "deno run -A --env --watch sda/main.ts"
10
10
  : runtime === "bun"
11
11
  ? "bun run --watch sda/main.ts"
12
- : "node --env-file=.env --watch sda/main.ts",
12
+ : "node --env-file=.env --watch --experimental-strip-types sda/main.ts",
13
13
  clean: "rm -rf .sda-cache .journalism-cache .tmp",
14
14
  };
15
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"installPackagesAndFetchDocs.d.ts","sourceRoot":"","sources":["../../src/helpers/installPackagesAndFetchDocs.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa;;CAEzB,CAAC;AAEF,wBAAsB,2BAA2B,CAC/C,gBAAgB,EAAE,MAAM,EAAE,EAC1B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmExB"}
1
+ {"version":3,"file":"installPackagesAndFetchDocs.d.ts","sourceRoot":"","sources":["../../src/helpers/installPackagesAndFetchDocs.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa;;CAEzB,CAAC;AAEF,wBAAsB,2BAA2B,CAC/C,gBAAgB,EAAE,MAAM,EAAE,EAC1B,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA4FxB"}
@@ -52,54 +52,76 @@ async function installPackagesAndFetchDocs(selectedPackages, options = {}) {
52
52
  let lastDoc = "";
53
53
  for (const pkg of selectedPackages) {
54
54
  const s = (0, prompts_1.spinner)();
55
- const installCmd = runtime === "deno"
56
- ? `deno add jsr:${pkg}`
57
- : runtime === "bun"
58
- ? `bun add ${pkg}`
59
- : `npm install ${pkg}`;
60
- if (!options.silent) {
61
- s.start(`Installing ${pkg} via ${runtime}...`);
55
+ const pkgsToInstall = [pkg];
56
+ if (pkg === "@nshiab/simple-data-analysis" ||
57
+ pkg === "@nshiab/journalism-dataviz") {
58
+ pkgsToInstall.push("@observablehq/plot");
62
59
  }
63
- try {
64
- await new Promise((resolve, reject) => {
65
- exports.commandRunner.exec(installCmd, (error) => {
66
- if (error) {
67
- reject(error);
68
- }
69
- else {
70
- resolve(void 0);
71
- }
72
- });
73
- });
60
+ for (const p of pkgsToInstall) {
61
+ const isObservablePlot = p === "@observablehq/plot";
62
+ const installCmd = runtime === "deno"
63
+ ? (isObservablePlot ? "deno add npm:" + p : "deno add jsr:" + p)
64
+ : runtime === "bun"
65
+ ? "bun add " + p
66
+ : "npm install " + p;
74
67
  if (!options.silent) {
75
- s.stop(`✅ ${pkg} installed!`);
68
+ s.start("Installing " + p + " via " + runtime + "...");
69
+ }
70
+ try {
71
+ await new Promise((resolve, reject) => {
72
+ exports.commandRunner.exec(installCmd, (error) => {
73
+ if (error) {
74
+ reject(error);
75
+ }
76
+ else {
77
+ resolve(void 0);
78
+ }
79
+ });
80
+ });
81
+ if (!options.silent) {
82
+ s.stop("✅ " + p + " installed!");
83
+ }
76
84
  }
77
- const sFetch = (0, prompts_1.spinner)();
85
+ catch (error) {
86
+ if (!options.silent) {
87
+ s.stop("❌ Failed to install " + p + ".");
88
+ }
89
+ throw error;
90
+ }
91
+ }
92
+ // Documentation logic
93
+ if (pkg === "@observablehq/plot") {
94
+ continue;
95
+ }
96
+ const sFetch = (0, prompts_1.spinner)();
97
+ try {
78
98
  if (!options.silent) {
79
- sFetch.start(`Fetching documentation for ${pkg}...`);
99
+ sFetch.start("Fetching documentation for " + pkg + "...");
80
100
  }
81
101
  const repoName = pkg.split("/")[1];
82
- const url = `https://raw.githubusercontent.com/nshiab/${repoName}/refs/heads/main/llm.md`;
102
+ const url = "https://raw.githubusercontent.com/nshiab/" + repoName +
103
+ "/refs/heads/main/llm.md";
83
104
  const response = await fetch(url);
84
105
  if (response.ok) {
85
106
  const docContent = await response.text();
86
- (0, node_fs_1.writeFileSync)((0, node_path_1.join)("docs", `${repoName}.md`), docContent);
107
+ (0, node_fs_1.writeFileSync)((0, node_path_1.join)("docs", repoName + ".md"), docContent);
87
108
  if (!options.silent) {
88
- sFetch.stop(`✅ Documentation for ${pkg} saved!`);
109
+ sFetch.stop("✅ Documentation for " + pkg + " saved!");
89
110
  }
90
111
  lastDoc = docContent;
91
112
  }
92
113
  else {
93
114
  if (!options.silent) {
94
- sFetch.stop(`⚠️ No documentation (llm.md) found for ${pkg}. Skipping doc fetch.`);
115
+ sFetch.stop("⚠️ No documentation (llm.md) found for " + pkg +
116
+ ". Skipping doc fetch.");
95
117
  }
96
118
  }
97
119
  }
98
120
  catch (error) {
99
121
  if (!options.silent) {
100
- s.stop(`❌ Failed to install ${pkg}.`);
122
+ sFetch.stop("❌ Failed to fetch documentation for " + pkg + ".");
101
123
  }
102
- throw error;
124
+ console.error(error);
103
125
  }
104
126
  }
105
127
  return lastDoc;