purus 0.11.0 → 1.1.0

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.
package/README-ja.md CHANGED
@@ -1,21 +1,21 @@
1
1
  <div align="center">
2
2
 
3
- [![Logo](https://raw.githubusercontent.com/otnc/purus/refs/heads/main/logo.png)](https://purus.work)
3
+ [![Logo](https://raw.githubusercontent.com/puruslang/assets/main/logo.png)](https://purus.work)
4
4
 
5
- [English](https://github.com/otnc/purus#readme) | **日本語**
5
+ [English](https://github.com/puruslang/purus#readme) | **日本語**
6
6
 
7
7
  </div>
8
8
 
9
9
  ---
10
10
 
11
- [![CI](https://github.com/otnc/purus/actions/workflows/ci.yml/badge.svg)](https://github.com/otnc/purus/actions/workflows/ci.yml)
11
+ [![CI](https://github.com/puruslang/purus/actions/workflows/ci.yml/badge.svg)](https://github.com/puruslang/purus/actions/workflows/ci.yml)
12
12
  [![npm](https://img.shields.io/npm/v/purus)](https://www.npmjs.com/package/purus)
13
13
  [![npm downloads](https://img.shields.io/npm/dm/purus)](https://www.npmjs.com/package/purus)
14
- [![License](https://img.shields.io/github/license/otnc/purus)](https://github.com/otnc/purus/blob/main/LICENSE)
15
- [![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org/)
14
+ [![License](https://img.shields.io/github/license/puruslang/purus)](https://github.com/puruslang/purus/blob/main/LICENSE)
15
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D22-brightgreen)](https://nodejs.org/)
16
16
  [![VS Code Extension](https://img.shields.io/visual-studio-marketplace/i/otoneko1102.purus)](https://marketplace.visualstudio.com/items?itemName=otoneko1102.purus)
17
- [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/otnc/purus)](https://github.com/otnc/purus/pulse)
18
- [![GitHub last commit](https://img.shields.io/github/last-commit/otnc/purus)](https://github.com/otnc/purus/commits/main)
17
+ [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/puruslang/purus)](https://github.com/puruslang/purus/pulse)
18
+ [![GitHub last commit](https://img.shields.io/github/last-commit/puruslang/purus)](https://github.com/puruslang/purus/commits/main)
19
19
  ![US layout](https://img.shields.io/badge/US_layout-Supported-green)
20
20
  ![JIS layout](https://img.shields.io/badge/JIS_layout-Supported-green)
21
21
 
@@ -27,8 +27,8 @@ Purusは、 _Shiftキー_ をほとんど押さずにプログラミングでき
27
27
 
28
28
  ```purus
29
29
  let name
30
- name be ///Purus///
31
- const message be ///Welcome to [name]!///
30
+ name be //;Purus;//
31
+ const message be //;Welcome to [name]!;//
32
32
  console.log[message] -- Welcome to Purus!
33
33
  ```
34
34
 
@@ -63,10 +63,10 @@ npm install -D purus
63
63
 
64
64
  ## 貢献
65
65
 
66
- ガイドは [コチラ](https://github.com/otnc/purus/blob/main/CONTRIBUTING-ja.md) !
66
+ ガイドは [コチラ](https://github.com/puruslang/purus/blob/main/CONTRIBUTING-ja.md) !
67
67
 
68
- <a href="https://github.com/otnc/purus/graphs/contributors">
69
- <img src="https://contrib.rocks/image?repo=otnc/purus" />
68
+ <a href="https://github.com/puruslang/purus/graphs/contributors">
69
+ <img src="https://contrib.rocks/image?repo=puruslang/purus" />
70
70
  </a>
71
71
 
72
72
  Made with [contrib.rocks](https://contrib.rocks).
@@ -77,4 +77,4 @@ otoneko. https://github.com/otnc
77
77
 
78
78
  ## ライセンス
79
79
 
80
- Apache 2.0 ライセンスに基づいて配布されます。詳細については、[LICENSE](https://raw.githubusercontent.com/otnc/purus/refs/heads/main/LICENSE) を参照してください。
80
+ Apache 2.0 ライセンスに基づいて配布されます。詳細については、[LICENSE](https://github.com/puruslang/purus/blob/main/LICENSE) を参照してください。
package/README.md CHANGED
@@ -1,21 +1,21 @@
1
1
  <div align="center">
2
2
 
3
- [![Logo](https://raw.githubusercontent.com/otnc/purus/refs/heads/main/logo.png)](https://purus.work)
3
+ [![Logo](https://raw.githubusercontent.com/puruslang/assets/main/logo.png)](https://purus.work)
4
4
 
5
- **English** | [日本語](https://github.com/otnc/purus/blob/main/README-ja.md)
5
+ **English** | [日本語](https://github.com/puruslang/purus/blob/main/README-ja.md)
6
6
 
7
7
  </div>
8
8
 
9
9
  ---
10
10
 
11
- [![CI](https://github.com/otnc/purus/actions/workflows/ci.yml/badge.svg)](https://github.com/otnc/purus/actions/workflows/ci.yml)
11
+ [![CI](https://github.com/puruslang/purus/actions/workflows/ci.yml/badge.svg)](https://github.com/puruslang/purus/actions/workflows/ci.yml)
12
12
  [![npm](https://img.shields.io/npm/v/purus)](https://www.npmjs.com/package/purus)
13
13
  [![npm downloads](https://img.shields.io/npm/dm/purus)](https://www.npmjs.com/package/purus)
14
- [![License](https://img.shields.io/github/license/otnc/purus)](https://github.com/otnc/purus/blob/main/LICENSE)
15
- [![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org/)
14
+ [![License](https://img.shields.io/github/license/puruslang/purus)](https://github.com/puruslang/purus/blob/main/LICENSE)
15
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D22-brightgreen)](https://nodejs.org/)
16
16
  [![VS Code Extension](https://img.shields.io/visual-studio-marketplace/i/otoneko1102.purus)](https://marketplace.visualstudio.com/items?itemName=otoneko1102.purus)
17
- [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/otnc/purus)](https://github.com/otnc/purus/pulse)
18
- [![GitHub last commit](https://img.shields.io/github/last-commit/otnc/purus)](https://github.com/otnc/purus/commits/main)
17
+ [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/puruslang/purus)](https://github.com/puruslang/purus/pulse)
18
+ [![GitHub last commit](https://img.shields.io/github/last-commit/puruslang/purus)](https://github.com/puruslang/purus/commits/main)
19
19
  ![US layout](https://img.shields.io/badge/US_layout-Supported-green)
20
20
  ![JIS layout](https://img.shields.io/badge/JIS_layout-Supported-green)
21
21
 
@@ -27,8 +27,8 @@ With Purus, you can write code almost without pressing the _Shift key_.
27
27
 
28
28
  ```purus
29
29
  let name
30
- name be ///Purus///
31
- const message be ///Welcome to [name]!///
30
+ name be //;Purus;//
31
+ const message be //;Welcome to [name]!;//
32
32
  console.log[message] -- Welcome to Purus!
33
33
  ```
34
34
 
@@ -63,10 +63,10 @@ The documentation is available on [purus.work](https://purus.work).
63
63
 
64
64
  ## Contribute
65
65
 
66
- The guide is [here](https://github.com/otnc/purus/blob/main/CONTRIBUTING.md)!
66
+ The guide is [here](https://github.com/puruslang/purus/blob/main/CONTRIBUTING.md)!
67
67
 
68
- <a href="https://github.com/otnc/purus/graphs/contributors">
69
- <img src="https://contrib.rocks/image?repo=otnc/purus" />
68
+ <a href="https://github.com/puruslang/purus/graphs/contributors">
69
+ <img src="https://contrib.rocks/image?repo=puruslang/purus" />
70
70
  </a>
71
71
 
72
72
  Made with [contrib.rocks](https://contrib.rocks).
@@ -77,4 +77,4 @@ otoneko. https://github.com/otnc
77
77
 
78
78
  ## License
79
79
 
80
- Distributed under the Apache 2.0 License. See [LICENSE](https://github.com/otnc/purus/blob/main/LICENSE) for more information.
80
+ Distributed under the Apache 2.0 License. See [LICENSE](https://github.com/puruslang/purus/blob/main/LICENSE) for more information.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "purus",
3
- "version": "0.11.0",
3
+ "version": "1.1.0",
4
4
  "description": "Purus - /ˈpuː.rus/ means pure✨ in Latin - is a beautiful, simple, and easy-to-use language. It compiles to JavaScript. It makes your fingers free from the Shift key. With Purus, you can write code almost without pressing the Shift key.",
5
5
  "main": "pkg/index.js",
6
6
  "module": "pkg/index.mjs",
@@ -50,18 +50,17 @@
50
50
  "license": "Apache-2.0",
51
51
  "repository": {
52
52
  "type": "git",
53
- "url": "https://github.com/otnc/purus",
54
- "directory": "core"
53
+ "url": "https://github.com/puruslang/purus"
55
54
  },
56
55
  "bugs": {
57
- "url": "https://github.com/otnc/purus/issues"
56
+ "url": "https://github.com/puruslang/purus/issues"
58
57
  },
59
58
  "funding": {
60
59
  "url": "https://github.com/sponsors/otnc"
61
60
  },
62
61
  "homepage": "https://purus.work",
63
62
  "engines": {
64
- "node": ">=20"
63
+ "node": ">=22"
65
64
  },
66
65
  "devDependencies": {
67
66
  "prettier": "^3.8.1"
package/pkg/lib/create.js CHANGED
@@ -5,6 +5,7 @@ const path = require("path");
5
5
  const readline = require("readline");
6
6
  const { spawnSync } = require("child_process");
7
7
  const { CONFIG_PURUS, PRETTIERRC, MAIN_PURUS, GITIGNORE } = require("./templates.js");
8
+ const pm = require("./pm.js");
8
9
 
9
10
  function question(rl, text) {
10
11
  return new Promise((resolve) => rl.question(text, (a) => resolve(a.trim())));
@@ -56,6 +57,10 @@ async function run() {
56
57
  // src/main.purus
57
58
  fs.writeFileSync(path.join(projectDir, "src/main.purus"), MAIN_PURUS);
58
59
 
60
+ // Detect the package manager from how we were launched (npx /
61
+ // pnpm dlx / yarn dlx / bunx), falling back to npm.
62
+ const manager = pm.detect(projectDir);
63
+
59
64
  // README.md
60
65
  const readme = `# ${projectName}
61
66
 
@@ -64,7 +69,7 @@ A [Purus](https://purus.work) project.
64
69
  ## Getting Started
65
70
 
66
71
  \`\`\`sh
67
- npm install
72
+ ${pm.installHint(manager)}
68
73
  purus build
69
74
  \`\`\`
70
75
 
@@ -72,10 +77,10 @@ purus build
72
77
 
73
78
  | Script | Description |
74
79
  |---|---|
75
- | \`npm run build\` | Compile Purus to JavaScript |
76
- | \`npm run exec\` | Run without compiling to files |
77
- | \`npm run format\` | Format with Prettier |
78
- | \`npm run lint\` | Lint with purus-lint |
80
+ | \`${manager} run build\` | Compile Purus to JavaScript |
81
+ | \`${manager} run exec\` | Run without compiling to files |
82
+ | \`${manager} run format\` | Format with Prettier |
83
+ | \`${manager} run lint\` | Lint with purus-lint |
79
84
  `;
80
85
  fs.writeFileSync(path.join(projectDir, "README.md"), readme);
81
86
 
@@ -88,22 +93,28 @@ purus build
88
93
  console.log(" README.md");
89
94
  console.log(" src/main.purus");
90
95
 
91
- // npm init
96
+ // Initialize package.json with the detected package manager
92
97
  console.log("");
93
- if (yesFlag) {
94
- console.log("Running npm init -y...");
95
- spawnSync("npm", ["init", "-y"], {
98
+ const initCmd = pm.initCommand(manager, yesFlag);
99
+ if (initCmd) {
100
+ console.log(`Running ${initCmd.cmd} ${initCmd.args.join(" ")}...`);
101
+ spawnSync(initCmd.cmd, initCmd.args, {
96
102
  cwd: projectDir,
97
103
  stdio: "inherit",
98
104
  shell: true,
99
105
  });
100
106
  } else {
101
- console.log("Running npm init...");
102
- spawnSync("npm", ["init"], {
103
- cwd: projectDir,
104
- stdio: "inherit",
105
- shell: true,
106
- });
107
+ // Managers whose init scaffolds extra files (e.g. bun) get a
108
+ // minimal package.json instead.
109
+ console.log("Creating package.json...");
110
+ fs.writeFileSync(
111
+ path.join(projectDir, "package.json"),
112
+ JSON.stringify(
113
+ { name: path.basename(projectDir), version: "1.0.0" },
114
+ null,
115
+ 2,
116
+ ) + "\n",
117
+ );
107
118
  }
108
119
 
109
120
  // Add scripts to package.json and set main/type
@@ -144,12 +155,13 @@ purus build
144
155
  "prettier",
145
156
  "purus",
146
157
  ];
147
- console.log("\nInstalling devDependencies...");
158
+ console.log(`\nInstalling devDependencies with ${manager}...`);
148
159
  for (const dep of devDeps) {
149
160
  console.log(` ${dep}`);
150
161
  }
151
162
  console.log("");
152
- spawnSync("npm", ["install", "--save-dev", ...devDeps], {
163
+ const addCmd = pm.addDevCommand(manager, devDeps);
164
+ spawnSync(addCmd.cmd, addCmd.args, {
153
165
  cwd: projectDir,
154
166
  stdio: "inherit",
155
167
  shell: true,
@@ -159,7 +171,7 @@ purus build
159
171
  console.log("\nDone! To get started:");
160
172
  console.log(` cd ${projectName}`);
161
173
  if (!installDeps) {
162
- console.log(" npm install");
174
+ console.log(` ${pm.installHint(manager)}`);
163
175
  }
164
176
  console.log(" purus build");
165
177
  } finally {
package/pkg/lib/init.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const fs = require("fs");
4
4
  const path = require("path");
5
5
  const { CONFIG_PURUS, PRETTIERRC, MAIN_PURUS, GITIGNORE } = require("./templates.js");
6
+ const pm = require("./pm.js");
6
7
 
7
8
  function run() {
8
9
  const cwd = process.cwd();
@@ -73,8 +74,9 @@ function run() {
73
74
  console.log(" package.json (skipped: scripts already set)");
74
75
  }
75
76
  } else {
77
+ const manager = pm.detect(cwd);
76
78
  console.log(
77
- "\nNo package.json found. Run `npm init` then `purus init` again to add scripts.",
79
+ `\nNo package.json found. Run \`${manager} init\` then \`purus init\` again to add scripts.`,
78
80
  );
79
81
  }
80
82
 
package/pkg/lib/pm.js ADDED
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Package manager detection and command mapping.
5
+ *
6
+ * Nothing is hardcoded to npm: the manager is detected from how the CLI
7
+ * was launched (npm_config_user_agent — set by `npx`, `pnpm dlx`,
8
+ * `yarn dlx`, `bunx`, and by `<pm> run` scripts), then from a lockfile
9
+ * in the target directory, and only falls back to npm as a default.
10
+ */
11
+
12
+ const fs = require("fs");
13
+ const path = require("path");
14
+
15
+ const KNOWN = new Set(["npm", "pnpm", "yarn", "bun"]);
16
+
17
+ const LOCKFILES = [
18
+ ["package-lock.json", "npm"],
19
+ ["pnpm-lock.yaml", "pnpm"],
20
+ ["yarn.lock", "yarn"],
21
+ ["bun.lock", "bun"],
22
+ ["bun.lockb", "bun"],
23
+ ];
24
+
25
+ function fromUserAgent() {
26
+ // e.g. "pnpm/9.12.0 npm/? node/v22.11.0 linux x64"
27
+ const ua = process.env.npm_config_user_agent || "";
28
+ const name = ua.split(" ")[0].split("/")[0];
29
+ return KNOWN.has(name) ? name : null;
30
+ }
31
+
32
+ function fromLockfile(dir) {
33
+ for (const [file, name] of LOCKFILES) {
34
+ if (fs.existsSync(path.join(dir, file))) return name;
35
+ }
36
+ return null;
37
+ }
38
+
39
+ /**
40
+ * Detect the package manager to use.
41
+ *
42
+ * @param {string} [dir] - Directory to check for lockfiles
43
+ * @returns {"npm"|"pnpm"|"yarn"|"bun"}
44
+ */
45
+ function detect(dir = process.cwd()) {
46
+ return fromUserAgent() || fromLockfile(dir) || "npm";
47
+ }
48
+
49
+ /**
50
+ * Command to initialize a package.json, or null when the manager's
51
+ * init scaffolds extra files (the caller should write a minimal
52
+ * package.json itself instead).
53
+ *
54
+ * @param {string} pm
55
+ * @param {boolean} yes - Non-interactive mode
56
+ * @returns {{ cmd: string, args: string[] } | null}
57
+ */
58
+ function initCommand(pm, yes) {
59
+ switch (pm) {
60
+ case "pnpm":
61
+ // pnpm init is always non-interactive
62
+ return { cmd: "pnpm", args: ["init"] };
63
+ case "yarn":
64
+ return { cmd: "yarn", args: yes ? ["init", "-y"] : ["init"] };
65
+ case "bun":
66
+ // bun init scaffolds index.ts/tsconfig — not wanted here
67
+ return null;
68
+ default:
69
+ return { cmd: "npm", args: yes ? ["init", "-y"] : ["init"] };
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Command to install packages as devDependencies.
75
+ *
76
+ * @param {string} pm
77
+ * @param {string[]} deps
78
+ * @returns {{ cmd: string, args: string[] }}
79
+ */
80
+ function addDevCommand(pm, deps) {
81
+ switch (pm) {
82
+ case "pnpm":
83
+ return { cmd: "pnpm", args: ["add", "-D", ...deps] };
84
+ case "yarn":
85
+ return { cmd: "yarn", args: ["add", "--dev", ...deps] };
86
+ case "bun":
87
+ return { cmd: "bun", args: ["add", "--dev", ...deps] };
88
+ default:
89
+ return { cmd: "npm", args: ["install", "--save-dev", ...deps] };
90
+ }
91
+ }
92
+
93
+ /**
94
+ * The plain "install dependencies" command shown in docs and hints.
95
+ *
96
+ * @param {string} pm
97
+ * @returns {string}
98
+ */
99
+ function installHint(pm) {
100
+ return pm === "yarn" ? "yarn" : `${pm} install`;
101
+ }
102
+
103
+ module.exports = { detect, initCommand, addDevCommand, installHint };