platformdirs 4.3.7 → 4.3.8-rc1

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.md CHANGED
@@ -4,8 +4,6 @@
4
4
 
5
5
  <table align=center><td>
6
6
 
7
- <div><sub><i>Running on Linux</i></sub></div>
8
-
9
7
  ```js
10
8
  const dirs = new PlatformDirs("awesome-app", "octocat", "1.2")
11
9
  console.log(dirs.userDataDir)
@@ -22,7 +20,7 @@ console.log(userLogDir("my-app", "gopher", "7.8"))
22
20
  </table>
23
21
 
24
22
  <p align=center>
25
- <a href="https://jsdocs.io/package/platformdirs">Documentation</a>
23
+ <a href="https://tsdocs.dev/docs/platformdirs">Documentation</a>
26
24
  | <a href="https://pypi.org/project/platformdirs/">Original <code>platformdirs</code> project</a>
27
25
  </p>
28
26
 
@@ -33,6 +31,9 @@ console.log(userLogDir("my-app", "gopher", "7.8"))
33
31
  ## Installation
34
32
 
35
33
  ![npm](https://img.shields.io/static/v1?style=for-the-badge&message=npm&color=CB3837&logo=npm&logoColor=FFFFFF&label=)
34
+ ![pnpm](https://img.shields.io/static/v1?style=for-the-badge&message=pnpm&color=222222&logo=pnpm&logoColor=F69220&label=)
35
+ ![Bun](https://img.shields.io/static/v1?style=for-the-badge&message=Bun&color=000000&logo=Bun&logoColor=FFFFFF&label=)
36
+ ![Deno](https://img.shields.io/static/v1?style=for-the-badge&message=Deno&color=222222&logo=Deno&logoColor=70FFAF&label=)
36
37
 
37
38
  You can install this package from [the npm registry](https://www.npmjs.com/) using npm, Yarn, pnpm, Bun, Deno, etc.
38
39
 
@@ -40,6 +41,8 @@ You can install this package from [the npm registry](https://www.npmjs.com/) usi
40
41
  npm install platformdirs
41
42
  ```
42
43
 
44
+ This package works with Node.js, Deno, and Bun. It is not intended to be used in the browser.
45
+
43
46
  ## Usage
44
47
 
45
48
  ![Node.js](https://img.shields.io/static/v1?style=for-the-badge&message=Node.js&color=5FA04E&logo=Node.js&logoColor=FFFFFF&label=)
@@ -64,7 +67,7 @@ if (!fs.existsSync(bigCSVPath)) {
64
67
  }
65
68
  ```
66
69
 
67
- 📚 For more information check out [the documentation](https://jsdocs.io/package/platformdirs)
70
+ 📚 For more information check out [the documentation](https://tsdocs.dev/docs/platformdirs)
68
71
 
69
72
  You can quickly dump all the directories for the current environment by running the included `platformdirs` CLI command. This is helpful for quickly determining what `dirs.userConfigDir` and friends return.
70
73
 
@@ -75,7 +78,74 @@ npx platformdirs
75
78
  <details><summary>Output on Windows</summary>
76
79
 
77
80
  ```
78
- TODO
81
+ -- platformdirs 4.3.7 --
82
+ -- app dirs (with optional 'version')
83
+ user_data_dir: C:\Users\me\AppData\Local\MyCompany\MyApp\1.0
84
+ user_config_dir: C:\Users\me\AppData\Local\MyCompany\MyApp\1.0
85
+ user_cache_dir: C:\Users\me\AppData\Local\MyCompany\MyApp\Cache\1.0
86
+ user_state_dir: C:\Users\me\AppData\Local\MyCompany\MyApp\1.0
87
+ user_log_dir: C:\Users\me\AppData\Local\MyCompany\MyApp\1.0\Logs
88
+ user_documents_dir: C:\Users\me\Documents
89
+ user_downloads_dir: C:\Users\me\Downloads
90
+ user_pictures_dir: C:\Users\me\Pictures
91
+ user_videos_dir: C:\Users\me\Videos
92
+ user_music_dir: C:\Users\me\Music
93
+ user_runtime_dir: C:\Users\me\AppData\Local\Temp\MyCompany\MyApp\1.0
94
+ site_data_dir: C:\ProgramData\MyCompany\MyApp\1.0
95
+ site_config_dir: C:\ProgramData\MyCompany\MyApp\1.0
96
+ site_cache_dir: C:\ProgramData\MyCompany\MyApp\Cache\1.0
97
+ site_runtime_dir: C:\Users\me\AppData\Local\Temp\MyCompany\MyApp\1.0
98
+
99
+ -- app dirs (without optional 'version')
100
+ user_data_dir: C:\Users\me\AppData\Local\MyCompany\MyApp
101
+ user_config_dir: C:\Users\me\AppData\Local\MyCompany\MyApp
102
+ user_cache_dir: C:\Users\me\AppData\Local\MyCompany\MyApp\Cache
103
+ user_state_dir: C:\Users\me\AppData\Local\MyCompany\MyApp
104
+ user_log_dir: C:\Users\me\AppData\Local\MyCompany\MyApp\Logs
105
+ user_documents_dir: C:\Users\me\Documents
106
+ user_downloads_dir: C:\Users\me\Downloads
107
+ user_pictures_dir: C:\Users\me\Pictures
108
+ user_videos_dir: C:\Users\me\Videos
109
+ user_music_dir: C:\Users\me\Music
110
+ user_runtime_dir: C:\Users\me\AppData\Local\Temp\MyCompany\MyApp
111
+ site_data_dir: C:\ProgramData\MyCompany\MyApp
112
+ site_config_dir: C:\ProgramData\MyCompany\MyApp
113
+ site_cache_dir: C:\ProgramData\MyCompany\MyApp\Cache
114
+ site_runtime_dir: C:\Users\me\AppData\Local\Temp\MyCompany\MyApp
115
+
116
+ -- app dirs (without optional 'appauthor')
117
+ user_data_dir: C:\Users\me\AppData\Local\MyApp\MyApp
118
+ user_config_dir: C:\Users\me\AppData\Local\MyApp\MyApp
119
+ user_cache_dir: C:\Users\me\AppData\Local\MyApp\MyApp\Cache
120
+ user_state_dir: C:\Users\me\AppData\Local\MyApp\MyApp
121
+ user_log_dir: C:\Users\me\AppData\Local\MyApp\MyApp\Logs
122
+ user_documents_dir: C:\Users\me\Documents
123
+ user_downloads_dir: C:\Users\me\Downloads
124
+ user_pictures_dir: C:\Users\me\Pictures
125
+ user_videos_dir: C:\Users\me\Videos
126
+ user_music_dir: C:\Users\me\Music
127
+ user_runtime_dir: C:\Users\me\AppData\Local\Temp\MyApp\MyApp
128
+ site_data_dir: C:\ProgramData\MyApp\MyApp
129
+ site_config_dir: C:\ProgramData\MyApp\MyApp
130
+ site_cache_dir: C:\ProgramData\MyApp\MyApp\Cache
131
+ site_runtime_dir: C:\Users\me\AppData\Local\Temp\MyApp\MyApp
132
+
133
+ -- app dirs (with disabled 'appauthor')
134
+ user_data_dir: C:\Users\me\AppData\Local\MyApp
135
+ user_config_dir: C:\Users\me\AppData\Local\MyApp
136
+ user_cache_dir: C:\Users\me\AppData\Local\MyApp\Cache
137
+ user_state_dir: C:\Users\me\AppData\Local\MyApp
138
+ user_log_dir: C:\Users\me\AppData\Local\MyApp\Logs
139
+ user_documents_dir: C:\Users\me\Documents
140
+ user_downloads_dir: C:\Users\me\Downloads
141
+ user_pictures_dir: C:\Users\me\Pictures
142
+ user_videos_dir: C:\Users\me\Videos
143
+ user_music_dir: C:\Users\me\Music
144
+ user_runtime_dir: C:\Users\me\AppData\Local\Temp\MyApp
145
+ site_data_dir: C:\ProgramData\MyApp
146
+ site_config_dir: C:\ProgramData\MyApp
147
+ site_cache_dir: C:\ProgramData\MyApp\Cache
148
+ site_runtime_dir: C:\Users\me\AppData\Local\Temp\MyApp
79
149
  ```
80
150
 
81
151
  </details>
@@ -169,4 +239,8 @@ site_runtime_dir: /run/MyApp
169
239
  ![TypeScript](https://img.shields.io/static/v1?style=for-the-badge&message=TypeScript&color=3178C6&logo=TypeScript&logoColor=FFFFFF&label=)
170
240
  ![Biome](https://img.shields.io/static/v1?style=for-the-badge&message=Biome&color=60A5FA&logo=Biome&logoColor=FFFFFF&label=)
171
241
 
172
- This project uses Node.js, TypeScript, and npm. Why Node.js instead of [Deno](https://deno.com/) & [JSR](https://jsr.io/)? Because it's not as popular (yet). I'd love to use Deno & JSR but nobody knows what they are. This project does use [Biome](https://biomejs.dev/) instead of the usual [Prettier](https://prettier.io/) & [ESLint](https://eslint.org/) combo. Why? Because ESLint bungled their v9 release and Biome offers a more cohesive linter & formatter solution.
242
+ This project uses Node.js, npm, TypeScript, and [Biome](https://biomejs.dev/) instead of the usual [Prettier](https://prettier.io/) & [ESLint](https://eslint.org/) combo. Why? Because ESLint bungled their v9 release and Biome offers a more cohesive linter & formatter solution.
243
+
244
+ For package releases make sure to always release a `-rc1` version first. If it's 100% OK then proceed to release it as normal. The goal is to keep the npm `platformdirs@X.Y.Z` package in sync with PyPI `platformdirs==X.Y.Z`.
245
+
246
+ So far I have failed at this and now I'm two patch versions _ahead_ of the Python package. Oopsies.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platformdirs",
3
- "version": "4.3.7",
3
+ "version": "4.3.8-rc1",
4
4
  "description": "📂 Unified interface to get platform-specific directories",
5
5
  "keywords": [
6
6
  "nodejs",
@@ -13,7 +13,7 @@
13
13
  "known-folders",
14
14
  "platformdirs"
15
15
  ],
16
- "homepage": "https://jsdocs.io/package/platformdirs",
16
+ "homepage": "https://tsdocs.dev/docs/platformdirs",
17
17
  "repository": {
18
18
  "type": "git",
19
19
  "url": "git+https://github.com/jcbhmr/platformdirs.js.git"
@@ -22,33 +22,30 @@
22
22
  "author": "Jacob Hummer <jcbhmr@outlook.com> (https://jcbhmr.me)",
23
23
  "type": "module",
24
24
  "exports": {
25
- ".": "./dist/index.js",
26
- "./android": "./dist/android.js",
27
- "./api": "./dist/api.js",
28
- "./macos": "./dist/macos.js",
29
- "./unix": "./dist/unix.js",
30
- "./version": "./dist/version.js"
25
+ ".": "./src/index.js",
26
+ "./android": "./src/android.js",
27
+ "./api": "./src/api.js",
28
+ "./macos": "./src/macos.js",
29
+ "./unix": "./src/unix.js",
30
+ "./version": "./src/version.js"
31
31
  },
32
32
  "bin": {
33
- "platformdirs": "dist/main.js"
33
+ "platformdirs": "src/main.js"
34
34
  },
35
- "files": [
36
- "dist"
37
- ],
35
+ "files": ["src"],
38
36
  "scripts": {
39
- "build": "tsc --noCheck",
40
37
  "format": "biome format --write .",
41
38
  "lint": "biome check --write . && tsc --noEmit",
42
- "run": "tsx src/main.ts",
43
- "test": "tsx --test",
44
- "prepack": "npm run build"
39
+ "run": "node src/main.js",
40
+ "test": "node --test"
45
41
  },
46
42
  "devDependencies": {
47
43
  "@biomejs/biome": "1.9.4",
48
44
  "@types/node": "^22.9.0",
45
+ "@types/which": "^3.0.4",
49
46
  "execa": "^9.5.1",
50
- "tsx": "^4.19.2",
51
- "typescript": "^5.6.3"
47
+ "typescript": "^5.6.3",
48
+ "which": "^5.0.0"
52
49
  },
53
50
  "engines": {
54
51
  "node": ">=18"
package/src/android.js ADDED
@@ -0,0 +1,203 @@
1
+ /**
2
+ * @module
3
+ * Android.
4
+ *
5
+ * TODO: Implement this module.
6
+ */
7
+
8
+ import * as path from "node:path";
9
+ import { PlatformDirsABC } from "./api.js";
10
+
11
+ /**
12
+ * @param {unknown} error
13
+ * @return {never}
14
+ */
15
+ function throwExpression(error) {
16
+ throw error;
17
+ }
18
+
19
+ /**
20
+ * Follows the guidance [from here](https://android.stackexchange.com/a/216132).
21
+ *
22
+ * Makes use of the {@link PlatformDirsABC.appname},
23
+ * {@link PlatformDirsABC.version}, {@link PlatformDirsABC.ensureExists}.
24
+ */
25
+ export class Android extends PlatformDirsABC {
26
+ /**
27
+ * @override
28
+ * @return {string} data directory tied to the user, e.g. `/data/user/<userid>/<packagename>/files/<AppName>`
29
+ */
30
+ get userDataDir() {
31
+ return this._appendAppNameAndVersion(
32
+ _androidFolder() ?? throwExpression(new Error("unreachable")),
33
+ "files",
34
+ );
35
+ }
36
+
37
+ /**
38
+ * @override
39
+ * @return {string} data directory shared by users, same as `userDataDir`
40
+ */
41
+ get siteDataDir() {
42
+ return this.userDataDir;
43
+ }
44
+
45
+ /**
46
+ * @override
47
+ * @return {string} config directory tied to the user, e.g. `/data/user/<userid>/<packagename>/shared_prefs/<AppName>`
48
+ */
49
+ get userConfigDir() {
50
+ return this._appendAppNameAndVersion(
51
+ _androidFolder() ?? throwExpression(new Error("unreachable")),
52
+ "shared_prefs",
53
+ );
54
+ }
55
+
56
+ /**
57
+ * @override
58
+ * @return {string} config directory shared by users, same as `userConfigDir`
59
+ */
60
+ get siteConfigDir() {
61
+ return this.userConfigDir;
62
+ }
63
+
64
+ /**
65
+ * @override
66
+ * @return {string} cache directory tied to the user, e.g. `/data/user/<userid>/<packagename>/cache/<AppName>`
67
+ */
68
+ get userCacheDir() {
69
+ return this._appendAppNameAndVersion(
70
+ _androidFolder() ?? throwExpression(new Error("unreachable")),
71
+ "cache",
72
+ );
73
+ }
74
+
75
+ /**
76
+ * @override
77
+ * @return {string} cache directory shared by users, same as `userCacheDir`
78
+ */
79
+ get siteCacheDir() {
80
+ return this.userCacheDir;
81
+ }
82
+
83
+ /**
84
+ * @override
85
+ * @return {string} state directory tied to the user, same as `userDataDir`
86
+ */
87
+ get userStateDir() {
88
+ return this.userDataDir;
89
+ }
90
+
91
+ /**
92
+ * @override
93
+ * @return {string} log directory tied to the user, same as `userCacheDir` if not opinionated else `log` in it, e.g. `/data/user/<userid>/<packagename>/cache/<AppName>/log`
94
+ */
95
+ get userLogDir() {
96
+ let path2 = this.userCacheDir;
97
+ if (this.opinion) {
98
+ path2 = path.join(path2, "log");
99
+ }
100
+ return path2;
101
+ }
102
+
103
+ /**
104
+ * @override
105
+ * @return {string} documents directory tied to the user, e.g. `/storage/emulated/0/Documents`
106
+ */
107
+ get userDocumentsDir() {
108
+ return androidDocumentsFolder();
109
+ }
110
+
111
+ /**
112
+ * @override
113
+ * @return {string} downloads directory tied to the user, e.g. `/storage/emulated/0/Downloads`
114
+ */
115
+ get userDownloadsDir() {
116
+ return androidDownloadsFolder();
117
+ }
118
+
119
+ /**
120
+ * @override
121
+ * @return {string} pictures directory tied to the user, e.g. `/storage/emulated/0/Pictures`
122
+ */
123
+ get userPicturesDir() {
124
+ return androidPicturesFolder();
125
+ }
126
+
127
+ /**
128
+ * @override
129
+ * @return {string} videos directory tied to the user, e.g. `/storage/emulated/0/Movies`
130
+ */
131
+ get userVideosDir() {
132
+ return androidVideosFolder();
133
+ }
134
+
135
+ /**
136
+ * @override
137
+ * @return {string} music directory tied to the user, e.g. `/storage/emulated/0/Music`
138
+ */
139
+ get userMusicDir() {
140
+ return androidMusicFolder();
141
+ }
142
+
143
+ /**
144
+ * @override
145
+ * @return {string} desktop directory tied to the user, e.g. `/storage/emulated/0/Desktop`
146
+ */
147
+ get userDesktopDir() {
148
+ return "/storage/emulated/0/Desktop";
149
+ }
150
+
151
+ /**
152
+ * @override
153
+ * @return {string} runtime directory tied to the user, same as `userCacheDir` if not opinionated else `tmp` in it, e.g. `/data/user/<userid>/<packagename>/cache/<AppName>/tmp`
154
+ */
155
+ get userRuntimeDir() {
156
+ let path2 = this.userCacheDir;
157
+ if (this.opinion) {
158
+ path2 = path.join(path2, "tmp");
159
+ }
160
+ return path2;
161
+ }
162
+
163
+ /**
164
+ * @override
165
+ * @return {string} runtime directory shared by users, same as `userRuntimeDir`
166
+ */
167
+ get siteRuntimeDir() {
168
+ return this.userRuntimeDir;
169
+ }
170
+ }
171
+
172
+ /**
173
+ * @return {string | undefined}
174
+ * @ignore @internal
175
+ */
176
+ export function _androidFolder() {
177
+ throw new Error("Not implemented");
178
+ }
179
+
180
+ /** @return {string} */
181
+ function androidDocumentsFolder() {
182
+ throw new Error("Not implemented");
183
+ }
184
+
185
+ /** @return {string} */
186
+ function androidDownloadsFolder() {
187
+ throw new Error("Not implemented");
188
+ }
189
+
190
+ /** @return {string} */
191
+ function androidPicturesFolder() {
192
+ throw new Error("Not implemented");
193
+ }
194
+
195
+ /** @return {string} */
196
+ function androidVideosFolder() {
197
+ throw new Error("Not implemented");
198
+ }
199
+
200
+ /** @return {string} */
201
+ function androidMusicFolder() {
202
+ throw new Error("Not implemented");
203
+ }