@ui-doc/node 0.2.1 → 0.2.2
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 +357 -2
- package/dist/NodeAssetLoader.d.ts +13 -8
- package/dist/NodeFileFinder.d.ts +1 -1
- package/dist/NodeFileSystem.d.ts +15 -12
- package/dist/index.cjs +49 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +48 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +32 -29
- package/LICENSE.md +0 -9
package/README.md
CHANGED
|
@@ -1,3 +1,358 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ui-doc/node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Node.js file system implementation for UI-Doc. This package provides file system operations, file discovery with glob patterns, and asset loading from node_modules packages.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ui-doc/node @ui-doc/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @ui-doc/node @ui-doc/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @ui-doc/node @ui-doc/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
`@ui-doc/node` implements the `FileSystem` interface from `@ui-doc/core`, providing:
|
|
22
|
+
|
|
23
|
+
- **File System Operations** - Read, write, copy files and directories
|
|
24
|
+
- **File Discovery** - Find files using glob patterns with picomatch
|
|
25
|
+
- **Asset Loading** - Resolve and load assets from node_modules packages
|
|
26
|
+
|
|
27
|
+
This package is typically used by build plugins (like `@ui-doc/rollup` or `@ui-doc/vite`) but can also be used directly for custom integrations.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Basic File System Operations
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { createNodeFileSystem } from '@ui-doc/node'
|
|
35
|
+
|
|
36
|
+
const fileSystem = createNodeFileSystem()
|
|
37
|
+
|
|
38
|
+
// Read a file
|
|
39
|
+
const content = await fileSystem.fileRead('./path/to/file.css')
|
|
40
|
+
|
|
41
|
+
// Write a file
|
|
42
|
+
await fileSystem.fileWrite('./output/file.html', '<html>...</html>')
|
|
43
|
+
|
|
44
|
+
// Check if file exists
|
|
45
|
+
const exists = await fileSystem.fileExists('./path/to/file.css')
|
|
46
|
+
|
|
47
|
+
// Copy a file
|
|
48
|
+
await fileSystem.fileCopy('./source.css', './destination.css')
|
|
49
|
+
|
|
50
|
+
// Copy a directory recursively
|
|
51
|
+
await fileSystem.directoryCopy('./source-dir', './dest-dir')
|
|
52
|
+
|
|
53
|
+
// Ensure directory exists (creates if needed)
|
|
54
|
+
await fileSystem.ensureDirectoryExists('./output/examples')
|
|
55
|
+
|
|
56
|
+
// Path utilities
|
|
57
|
+
const basename = fileSystem.fileBasename('./path/to/file.css') // "file"
|
|
58
|
+
const dirname = fileSystem.fileDirname('./path/to/file.css') // "./path/to"
|
|
59
|
+
const resolved = fileSystem.resolve('./relative/path') // Absolute path
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### File Discovery with Glob Patterns
|
|
63
|
+
|
|
64
|
+
The `NodeFileFinder` class searches for files matching glob patterns:
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
import { createNodeFileSystem } from '@ui-doc/node'
|
|
68
|
+
|
|
69
|
+
const fileSystem = createNodeFileSystem()
|
|
70
|
+
const finder = fileSystem.createFileFinder([
|
|
71
|
+
'src/**/*.css',
|
|
72
|
+
'components/**/*.js',
|
|
73
|
+
'styles/**/*.scss',
|
|
74
|
+
])
|
|
75
|
+
|
|
76
|
+
// Search for all matching files
|
|
77
|
+
await finder.search(async filePath => {
|
|
78
|
+
// Process the file
|
|
79
|
+
await fileSystem.fileRead(filePath)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
// Check if a specific file matches the patterns
|
|
83
|
+
finder.matches('./src/components/Button.css') // true
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Loading Assets from node_modules
|
|
87
|
+
|
|
88
|
+
The `NodeAssetLoader` helps resolve and load assets from installed packages:
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
import { createNodeFileSystem } from '@ui-doc/node'
|
|
92
|
+
|
|
93
|
+
const fileSystem = createNodeFileSystem()
|
|
94
|
+
const assetLoader = fileSystem.assetLoader()
|
|
95
|
+
|
|
96
|
+
// Check if a package exists
|
|
97
|
+
await assetLoader.packageExists('@highlightjs/cdn-assets')
|
|
98
|
+
|
|
99
|
+
// Get the path to a package
|
|
100
|
+
await assetLoader.packagePath('@ui-doc/html-renderer')
|
|
101
|
+
|
|
102
|
+
// Resolve a file within a package
|
|
103
|
+
await assetLoader.resolve('@ui-doc/html-renderer/ui-doc.min.css')
|
|
104
|
+
|
|
105
|
+
// Read an asset from a package
|
|
106
|
+
await assetLoader.read('@ui-doc/html-renderer/ui-doc.min.css')
|
|
107
|
+
|
|
108
|
+
// Copy an asset from a package to your output
|
|
109
|
+
await assetLoader.copy(
|
|
110
|
+
'@ui-doc/html-renderer/ui-doc.min.css',
|
|
111
|
+
'./dist/ui-doc.css',
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Complete Example
|
|
116
|
+
|
|
117
|
+
Here's a complete example showing how to use `@ui-doc/node` with `@ui-doc/core`:
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
import { UIDoc } from '@ui-doc/core'
|
|
121
|
+
import { HtmlRenderer, NodeParser, TemplateLoader } from '@ui-doc/html-renderer'
|
|
122
|
+
import { createNodeFileSystem } from '@ui-doc/node'
|
|
123
|
+
|
|
124
|
+
async function generateDocs() {
|
|
125
|
+
const outputDir = './dist/docs'
|
|
126
|
+
|
|
127
|
+
// Initialize file system
|
|
128
|
+
const fileSystem = createNodeFileSystem()
|
|
129
|
+
const assetLoader = fileSystem.assetLoader()
|
|
130
|
+
|
|
131
|
+
// Create renderer
|
|
132
|
+
const renderer = new HtmlRenderer(NodeParser.init())
|
|
133
|
+
|
|
134
|
+
// Load templates
|
|
135
|
+
const templatePath = await assetLoader.packagePath(TemplateLoader.TEMPLATES_PACKAGE)
|
|
136
|
+
if (templatePath) {
|
|
137
|
+
await TemplateLoader.load({ fileSystem, renderer, templatePath })
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Initialize UI-Doc
|
|
141
|
+
const uidoc = new UIDoc({ renderer })
|
|
142
|
+
|
|
143
|
+
// Find and parse source files
|
|
144
|
+
const finder = fileSystem.createFileFinder(['src/**/*.css', 'src/**/*.js'])
|
|
145
|
+
await finder.search(async file => {
|
|
146
|
+
const content = await fileSystem.fileRead(file)
|
|
147
|
+
uidoc.sourceCreate(file, content)
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
// Create output directory
|
|
151
|
+
await fileSystem.ensureDirectoryExists(outputDir)
|
|
152
|
+
await fileSystem.ensureDirectoryExists(`${outputDir}/examples`)
|
|
153
|
+
|
|
154
|
+
// Write documentation output
|
|
155
|
+
await uidoc.output(async (file, content) => {
|
|
156
|
+
await fileSystem.fileWrite(`${outputDir}/${file}`, content)
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
// Copy required assets
|
|
160
|
+
await assetLoader.copy('@ui-doc/html-renderer/ui-doc.min.css', `${outputDir}/ui-doc.css`)
|
|
161
|
+
await assetLoader.copy('@ui-doc/html-renderer/ui-doc.min.js', `${outputDir}/ui-doc.js`)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
generateDocs()
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## API Reference
|
|
168
|
+
|
|
169
|
+
### NodeFileSystem
|
|
170
|
+
|
|
171
|
+
The main class implementing the `FileSystem` interface.
|
|
172
|
+
|
|
173
|
+
#### Static Methods
|
|
174
|
+
|
|
175
|
+
##### `NodeFileSystem.init(): NodeFileSystem`
|
|
176
|
+
|
|
177
|
+
Creates or returns the singleton instance of `NodeFileSystem`.
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
import { NodeFileSystem } from '@ui-doc/node'
|
|
181
|
+
|
|
182
|
+
NodeFileSystem.init()
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### Instance Methods
|
|
186
|
+
|
|
187
|
+
##### `createFileFinder(globs: string[]): NodeFileFinder`
|
|
188
|
+
|
|
189
|
+
Creates a file finder for the given glob patterns.
|
|
190
|
+
|
|
191
|
+
##### `assetLoader(): NodeAssetLoader`
|
|
192
|
+
|
|
193
|
+
Returns the asset loader instance.
|
|
194
|
+
|
|
195
|
+
##### `resolve(file: string): string`
|
|
196
|
+
|
|
197
|
+
Resolves a file path to an absolute path.
|
|
198
|
+
|
|
199
|
+
##### `fileRead(file: string): Promise<string>`
|
|
200
|
+
|
|
201
|
+
Reads a file and returns its content as a string.
|
|
202
|
+
|
|
203
|
+
##### `fileWrite(file: string, content: string): Promise<boolean>`
|
|
204
|
+
|
|
205
|
+
Writes content to a file. Returns `true` on success, `false` on failure.
|
|
206
|
+
|
|
207
|
+
##### `fileCopy(from: string, to: string): Promise<boolean>`
|
|
208
|
+
|
|
209
|
+
Copies a file. Returns `true` on success, `false` on failure.
|
|
210
|
+
|
|
211
|
+
##### `fileExists(file: string): Promise<boolean>`
|
|
212
|
+
|
|
213
|
+
Checks if a file exists.
|
|
214
|
+
|
|
215
|
+
##### `fileBasename(file: string): string`
|
|
216
|
+
|
|
217
|
+
Returns the filename without extension.
|
|
218
|
+
|
|
219
|
+
##### `fileDirname(file: string): string`
|
|
220
|
+
|
|
221
|
+
Returns the directory path.
|
|
222
|
+
|
|
223
|
+
##### `ensureDirectoryExists(dir: string): Promise<boolean>`
|
|
224
|
+
|
|
225
|
+
Creates a directory and all parent directories if they don't exist.
|
|
226
|
+
|
|
227
|
+
##### `isDirectory(dir: string): Promise<boolean>`
|
|
228
|
+
|
|
229
|
+
Checks if a path is a directory.
|
|
230
|
+
|
|
231
|
+
##### `directoryCopy(from: string, to: string): Promise<boolean>`
|
|
232
|
+
|
|
233
|
+
Recursively copies a directory. Returns `true` if all files were copied successfully.
|
|
234
|
+
|
|
235
|
+
### NodeFileFinder
|
|
236
|
+
|
|
237
|
+
Discovers files matching glob patterns.
|
|
238
|
+
|
|
239
|
+
#### Constructor
|
|
240
|
+
|
|
241
|
+
```text
|
|
242
|
+
import { NodeFileFinder } from '@ui-doc/node'
|
|
243
|
+
|
|
244
|
+
new NodeFileFinder(['src/**/*.css', 'components/**/*.js'])
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
#### Properties
|
|
248
|
+
|
|
249
|
+
##### `globs: readonly string[]`
|
|
250
|
+
|
|
251
|
+
The resolved glob patterns.
|
|
252
|
+
|
|
253
|
+
#### Methods
|
|
254
|
+
|
|
255
|
+
##### `search(onFound: (file: string) => Promise<void> | void): Promise<void>`
|
|
256
|
+
|
|
257
|
+
Searches for all files matching the glob patterns and calls `onFound` for each match.
|
|
258
|
+
|
|
259
|
+
##### `matches(file: string): boolean`
|
|
260
|
+
|
|
261
|
+
Checks if a file path matches any of the glob patterns.
|
|
262
|
+
|
|
263
|
+
### NodeAssetLoader
|
|
264
|
+
|
|
265
|
+
Loads assets from node_modules packages.
|
|
266
|
+
|
|
267
|
+
#### Constructor
|
|
268
|
+
|
|
269
|
+
The `NodeAssetLoader` is typically accessed via `fileSystem.assetLoader()` rather than instantiated directly.
|
|
270
|
+
|
|
271
|
+
#### Methods
|
|
272
|
+
|
|
273
|
+
##### `packageExists(packageName: string): Promise<boolean>`
|
|
274
|
+
|
|
275
|
+
Checks if a package is installed.
|
|
276
|
+
|
|
277
|
+
##### `packagePath(packageName: string): Promise<string | undefined>`
|
|
278
|
+
|
|
279
|
+
Returns the absolute path to a package, or `undefined` if not found.
|
|
280
|
+
|
|
281
|
+
##### `resolve(file: string): Promise<string | undefined>`
|
|
282
|
+
|
|
283
|
+
Resolves a file path (package or module specifier) to an absolute path.
|
|
284
|
+
|
|
285
|
+
##### `read(file: string): Promise<string>`
|
|
286
|
+
|
|
287
|
+
Reads a file from a package and returns its content. Throws an error if the file cannot be resolved.
|
|
288
|
+
|
|
289
|
+
##### `copy(from: string, to: string): Promise<void>`
|
|
290
|
+
|
|
291
|
+
Copies an asset from a package to a destination path. Throws an error if the source cannot be resolved.
|
|
292
|
+
|
|
293
|
+
## Helper Functions
|
|
294
|
+
|
|
295
|
+
### `createNodeFileSystem(): NodeFileSystem`
|
|
296
|
+
|
|
297
|
+
Convenience function that calls `NodeFileSystem.init()`.
|
|
298
|
+
|
|
299
|
+
```js
|
|
300
|
+
import { createNodeFileSystem } from '@ui-doc/node'
|
|
301
|
+
|
|
302
|
+
createNodeFileSystem()
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Glob Pattern Examples
|
|
306
|
+
|
|
307
|
+
The file finder supports picomatch glob patterns:
|
|
308
|
+
|
|
309
|
+
```text
|
|
310
|
+
// Match all CSS files in src directory (non-recursive)
|
|
311
|
+
['src/*.css']
|
|
312
|
+
|
|
313
|
+
// Match all CSS files recursively
|
|
314
|
+
['src/**/*.css']
|
|
315
|
+
|
|
316
|
+
// Match multiple file types
|
|
317
|
+
['src/**/*.{css,scss,sass}']
|
|
318
|
+
|
|
319
|
+
// Match files in multiple directories
|
|
320
|
+
['src/**/*.css', 'components/**/*.css', 'styles/**/*.css']
|
|
321
|
+
|
|
322
|
+
// Exclude patterns using negative globs
|
|
323
|
+
['src/**/*.css', '!src/**/*.test.css']
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## TypeScript Support
|
|
327
|
+
|
|
328
|
+
This package is written in TypeScript and includes type definitions. All exports are fully typed.
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
import type { AssetLoader, FileFinder, FileSystem } from '@ui-doc/core'
|
|
332
|
+
import { createNodeFileSystem } from '@ui-doc/node'
|
|
333
|
+
|
|
334
|
+
const fileSystem: FileSystem = createNodeFileSystem()
|
|
335
|
+
const finder: FileFinder = fileSystem.createFileFinder(['**/*.css'])
|
|
336
|
+
const assetLoader: AssetLoader = fileSystem.assetLoader()
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Requirements
|
|
340
|
+
|
|
341
|
+
- Node.js >= 16.0.0
|
|
342
|
+
|
|
343
|
+
## License
|
|
344
|
+
|
|
345
|
+
MIT
|
|
346
|
+
|
|
347
|
+
## Related Packages
|
|
348
|
+
|
|
349
|
+
- [@ui-doc/core](../core) - Core parsing and context generation
|
|
350
|
+
- [@ui-doc/html-renderer](../html-renderer) - HTML output renderer
|
|
351
|
+
- [@ui-doc/rollup](../rollup) - Rollup plugin integration
|
|
352
|
+
- [@ui-doc/vite](../vite) - Vite plugin integration
|
|
353
|
+
|
|
354
|
+
## Links
|
|
355
|
+
|
|
356
|
+
- [GitHub Repository](https://github.com/gherrink/ui-doc)
|
|
357
|
+
- [Issue Tracker](https://github.com/gherrink/ui-doc/issues)
|
|
358
|
+
- [Changelog](./CHANGELOG.md)
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import type { AssetLoader, FileSystem } from '@ui-doc/core';
|
|
1
|
+
import type { AssetLoader, FilePath, FileSystem } from '@ui-doc/core';
|
|
3
2
|
export declare class NodeAssetLoader implements AssetLoader {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
private resolvedPackages;
|
|
4
|
+
private readonly fileSystem;
|
|
5
|
+
private readonly require;
|
|
7
6
|
constructor(fileSystem: FileSystem);
|
|
8
7
|
packageExists(packageName: string): Promise<boolean>;
|
|
9
8
|
packagePath(packageName: string): Promise<string | undefined>;
|
|
10
|
-
resolve(file:
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
resolve(file: FilePath): Promise<string | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Copies an asset from a resolved package path to a destination.
|
|
12
|
+
* @param from - Source path relative to node_modules
|
|
13
|
+
* @param to - Destination path
|
|
14
|
+
* @throws Error if the source asset cannot be resolved
|
|
15
|
+
*/
|
|
16
|
+
copy(from: FilePath, to: FilePath): Promise<void>;
|
|
17
|
+
read(file: FilePath): Promise<string>;
|
|
13
18
|
}
|
package/dist/NodeFileFinder.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FileFinder, FileFinderOnFoundCallback } from '@ui-doc/core';
|
|
2
2
|
export declare class NodeFileFinder implements FileFinder {
|
|
3
|
-
globs: string[];
|
|
3
|
+
readonly globs: readonly string[];
|
|
4
4
|
constructor(globs?: string[]);
|
|
5
5
|
search(fileFound: FileFinderOnFoundCallback): Promise<void>;
|
|
6
6
|
protected searchGlob(glob: string, fileFound: FileFinderOnFoundCallback): Promise<Promise<void>[]>;
|
package/dist/NodeFileSystem.d.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import type { FileSystem } from '@ui-doc/core';
|
|
1
|
+
import type { FilePath, FileSystem } from '@ui-doc/core';
|
|
2
2
|
import { NodeAssetLoader } from './NodeAssetLoader';
|
|
3
3
|
import { NodeFileFinder } from './NodeFileFinder';
|
|
4
4
|
export declare class NodeFileSystem implements FileSystem {
|
|
5
5
|
private static instance;
|
|
6
6
|
private assetLoaderInstance?;
|
|
7
|
+
private constructor();
|
|
7
8
|
static init(): NodeFileSystem;
|
|
8
9
|
createFileFinder(globs: string[]): NodeFileFinder;
|
|
9
10
|
assetLoader(): NodeAssetLoader;
|
|
10
|
-
resolve(file:
|
|
11
|
-
fileRead(file:
|
|
12
|
-
fileWrite(file:
|
|
13
|
-
fileCopy(from:
|
|
14
|
-
fileExists(file:
|
|
15
|
-
fileBasename(file:
|
|
16
|
-
fileDirname(file:
|
|
17
|
-
ensureDirectoryExists(dir:
|
|
18
|
-
isDirectory(dir:
|
|
19
|
-
directoryCopy(from:
|
|
11
|
+
resolve(file: FilePath): FilePath;
|
|
12
|
+
fileRead(file: FilePath): Promise<string>;
|
|
13
|
+
fileWrite(file: FilePath, content: string): Promise<boolean>;
|
|
14
|
+
fileCopy(from: FilePath, to: FilePath): Promise<boolean>;
|
|
15
|
+
fileExists(file: FilePath): Promise<boolean>;
|
|
16
|
+
fileBasename(file: FilePath): string;
|
|
17
|
+
fileDirname(file: FilePath): string;
|
|
18
|
+
ensureDirectoryExists(dir: FilePath): Promise<boolean>;
|
|
19
|
+
isDirectory(dir: FilePath): Promise<boolean>;
|
|
20
|
+
directoryCopy(from: FilePath, to: FilePath): Promise<boolean>;
|
|
20
21
|
}
|
|
21
|
-
export declare function
|
|
22
|
+
export declare function createNodeFileSystem(): NodeFileSystem;
|
|
23
|
+
/** @deprecated Use createNodeFileSystem instead */
|
|
24
|
+
export declare const cerateNodeFileSystem: typeof createNodeFileSystem;
|
package/dist/index.cjs
CHANGED
|
@@ -6,10 +6,11 @@ var path = require('node:path');
|
|
|
6
6
|
var picomatch = require('picomatch');
|
|
7
7
|
|
|
8
8
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
9
|
-
/* eslint-disable no-empty-function */
|
|
10
9
|
class NodeAssetLoader {
|
|
10
|
+
resolvedPackages = {};
|
|
11
|
+
fileSystem;
|
|
12
|
+
require;
|
|
11
13
|
constructor(fileSystem) {
|
|
12
|
-
this.resolvedPackages = {};
|
|
13
14
|
this.fileSystem = fileSystem;
|
|
14
15
|
this.require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
15
16
|
}
|
|
@@ -20,42 +21,46 @@ class NodeAssetLoader {
|
|
|
20
21
|
if (this.resolvedPackages[packageName] !== undefined) {
|
|
21
22
|
return this.resolvedPackages[packageName] === null
|
|
22
23
|
? undefined
|
|
23
|
-
: this.resolvedPackages[packageName];
|
|
24
|
+
: this.resolvedPackages[packageName] ?? undefined;
|
|
24
25
|
}
|
|
25
26
|
const paths = this.require.resolve.paths(packageName);
|
|
26
27
|
if (!paths) {
|
|
27
28
|
throw new Error('Could not resolve require paths');
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
if ((await acc) !== null) {
|
|
31
|
-
return acc;
|
|
32
|
-
}
|
|
30
|
+
for (const nodePath of paths) {
|
|
33
31
|
const dir = path.join(nodePath, packageName);
|
|
34
|
-
|
|
32
|
+
const exists = await fs
|
|
35
33
|
.access(dir, fs.constants.R_OK)
|
|
36
34
|
.then(() => true)
|
|
37
|
-
.catch(() => false)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
.catch(() => false);
|
|
36
|
+
if (exists) {
|
|
37
|
+
this.resolvedPackages[packageName] = dir;
|
|
38
|
+
return dir;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
this.resolvedPackages[packageName] = null;
|
|
42
|
+
return undefined;
|
|
44
43
|
}
|
|
45
44
|
async resolve(file) {
|
|
46
45
|
const resolvedFile = this.require.resolve(file);
|
|
47
46
|
return (await this.fileSystem.fileExists(resolvedFile)) ? resolvedFile : undefined;
|
|
48
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Copies an asset from a resolved package path to a destination.
|
|
50
|
+
* @param from - Source path relative to node_modules
|
|
51
|
+
* @param to - Destination path
|
|
52
|
+
* @throws Error if the source asset cannot be resolved
|
|
53
|
+
*/
|
|
49
54
|
async copy(from, to) {
|
|
50
55
|
const fromPath = await this.resolve(from);
|
|
51
|
-
if (
|
|
56
|
+
if (fromPath === undefined || fromPath === '') {
|
|
52
57
|
throw new Error(`Could not resolve source asset "${from}"`);
|
|
53
58
|
}
|
|
54
59
|
await this.fileSystem.fileCopy(fromPath, to);
|
|
55
60
|
}
|
|
56
61
|
async read(file) {
|
|
57
62
|
const fromPath = await this.resolve(file);
|
|
58
|
-
if (
|
|
63
|
+
if (fromPath === undefined || fromPath === '') {
|
|
59
64
|
throw new Error(`Could not resolve asset "${file}"`);
|
|
60
65
|
}
|
|
61
66
|
return this.fileSystem.fileRead(fromPath);
|
|
@@ -63,14 +68,15 @@ class NodeAssetLoader {
|
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
class NodeFileFinder {
|
|
71
|
+
globs;
|
|
66
72
|
constructor(globs = []) {
|
|
67
|
-
this.globs = [];
|
|
68
73
|
this.globs = globs.map(glob => path.resolve(glob));
|
|
69
74
|
}
|
|
70
75
|
async search(fileFound) {
|
|
71
|
-
|
|
76
|
+
const searchResults = await Promise.all(this.globs.map(async (glob) => this.searchGlob(glob, fileFound)));
|
|
77
|
+
await Promise.all(searchResults.flat());
|
|
72
78
|
}
|
|
73
|
-
searchGlob(glob, fileFound) {
|
|
79
|
+
async searchGlob(glob, fileFound) {
|
|
74
80
|
const scan = picomatch.scan(glob, { parts: true, tokens: true });
|
|
75
81
|
const pathBase = path.join(scan.prefix, scan.base);
|
|
76
82
|
const recursive = scan.maxDepth === Infinity;
|
|
@@ -102,8 +108,11 @@ class NodeFileFinder {
|
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
class NodeFileSystem {
|
|
111
|
+
static instance;
|
|
112
|
+
assetLoaderInstance;
|
|
113
|
+
constructor() { }
|
|
105
114
|
static init() {
|
|
106
|
-
if (
|
|
115
|
+
if (this.instance === undefined) {
|
|
107
116
|
this.instance = new NodeFileSystem();
|
|
108
117
|
}
|
|
109
118
|
return this.instance;
|
|
@@ -124,24 +133,16 @@ class NodeFileSystem {
|
|
|
124
133
|
return fs.readFile(this.resolve(file), 'utf8');
|
|
125
134
|
}
|
|
126
135
|
async fileWrite(file, content) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
catch (e) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
136
|
+
return fs
|
|
137
|
+
.writeFile(this.resolve(file), content, 'utf8')
|
|
138
|
+
.then(() => true)
|
|
139
|
+
.catch(() => false);
|
|
134
140
|
}
|
|
135
141
|
async fileCopy(from, to) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
catch (e) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
142
|
+
return fs
|
|
143
|
+
.copyFile(this.resolve(from), this.resolve(to))
|
|
144
|
+
.then(() => true)
|
|
145
|
+
.catch(() => false);
|
|
145
146
|
}
|
|
146
147
|
async fileExists(file) {
|
|
147
148
|
return fs
|
|
@@ -160,13 +161,10 @@ class NodeFileSystem {
|
|
|
160
161
|
return true;
|
|
161
162
|
}
|
|
162
163
|
async isDirectory(dir) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
catch (e) {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
164
|
+
return fs
|
|
165
|
+
.stat(this.resolve(dir))
|
|
166
|
+
.then(stats => stats.isDirectory())
|
|
167
|
+
.catch(() => false);
|
|
170
168
|
}
|
|
171
169
|
async directoryCopy(from, to) {
|
|
172
170
|
const fromDir = this.resolve(from);
|
|
@@ -178,19 +176,23 @@ class NodeFileSystem {
|
|
|
178
176
|
const res = await Promise.all(dirents.map(async (dirent) => {
|
|
179
177
|
const fromPath = path.join(fromDir, dirent.name);
|
|
180
178
|
const toPath = path.join(toDir, dirent.name);
|
|
181
|
-
return
|
|
179
|
+
return dirent.isDirectory()
|
|
182
180
|
? this.directoryCopy(fromPath, toPath)
|
|
183
181
|
: this.fileCopy(fromPath, toPath);
|
|
184
182
|
}));
|
|
185
|
-
return
|
|
183
|
+
return res.every(value => value === true);
|
|
186
184
|
}
|
|
187
185
|
}
|
|
188
|
-
function
|
|
186
|
+
function createNodeFileSystem() {
|
|
189
187
|
return NodeFileSystem.init();
|
|
190
188
|
}
|
|
189
|
+
/** @deprecated Use createNodeFileSystem instead */
|
|
190
|
+
const cerateNodeFileSystem = createNodeFileSystem;
|
|
191
191
|
|
|
192
192
|
exports.NodeAssetLoader = NodeAssetLoader;
|
|
193
193
|
exports.NodeFileFinder = NodeFileFinder;
|
|
194
194
|
exports.NodeFileSystem = NodeFileSystem;
|
|
195
195
|
exports.cerateNodeFileSystem = cerateNodeFileSystem;
|
|
196
|
+
exports.createNodeFileSystem = createNodeFileSystem;
|
|
197
|
+
if (exports.default) { module.exports = Object.assign(exports.default, exports); }
|
|
196
198
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/NodeAssetLoader.ts","../src/NodeFileFinder.ts","../src/NodeFileSystem.ts"],"sourcesContent":[null,null,null],"names":["createRequire"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/NodeAssetLoader.ts","../src/NodeFileFinder.ts","../src/NodeFileSystem.ts"],"sourcesContent":[null,null,null],"names":["createRequire"],"mappings":";;;;;;;;MAMa,eAAe,CAAA;IAClB,gBAAgB,GAAkC,EAAE,CAAA;AAE3C,IAAA,UAAU,CAAY;AAEtB,IAAA,OAAO,CAAa;AAErC,IAAA,WAAA,CAAmB,UAAsB,EAAA;AACvC,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAGA,yBAAa,CAAC,8LAAe,CAAC,CAAA;KAC9C;IAEM,MAAM,aAAa,CAAC,WAAmB,EAAA;QAC5C,OAAO,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,SAAS,CAAA;KAC3D;IAEM,MAAM,WAAW,CAAC,WAAmB,EAAA;QAC1C,IAAI,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,SAAS,EAAE;AACpD,YAAA,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,IAAI;AAChD,kBAAE,SAAS;kBACT,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,IAAI,SAAS,CAAA;SACpD;AAED,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAA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F,CAAA;SAEe,oBAAoB,GAAA;AAClC,IAAA,OAAO,cAAc,CAAC,IAAI,EAAE,CAAA;AAC9B,CAAC;AAED;AACO,MAAM,oBAAoB,GAAG;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -3,10 +3,11 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import picomatch from 'picomatch';
|
|
5
5
|
|
|
6
|
-
/* eslint-disable no-empty-function */
|
|
7
6
|
class NodeAssetLoader {
|
|
7
|
+
resolvedPackages = {};
|
|
8
|
+
fileSystem;
|
|
9
|
+
require;
|
|
8
10
|
constructor(fileSystem) {
|
|
9
|
-
this.resolvedPackages = {};
|
|
10
11
|
this.fileSystem = fileSystem;
|
|
11
12
|
this.require = createRequire(import.meta.url);
|
|
12
13
|
}
|
|
@@ -17,42 +18,46 @@ class NodeAssetLoader {
|
|
|
17
18
|
if (this.resolvedPackages[packageName] !== undefined) {
|
|
18
19
|
return this.resolvedPackages[packageName] === null
|
|
19
20
|
? undefined
|
|
20
|
-
: this.resolvedPackages[packageName];
|
|
21
|
+
: this.resolvedPackages[packageName] ?? undefined;
|
|
21
22
|
}
|
|
22
23
|
const paths = this.require.resolve.paths(packageName);
|
|
23
24
|
if (!paths) {
|
|
24
25
|
throw new Error('Could not resolve require paths');
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
if ((await acc) !== null) {
|
|
28
|
-
return acc;
|
|
29
|
-
}
|
|
27
|
+
for (const nodePath of paths) {
|
|
30
28
|
const dir = path.join(nodePath, packageName);
|
|
31
|
-
|
|
29
|
+
const exists = await fs
|
|
32
30
|
.access(dir, fs.constants.R_OK)
|
|
33
31
|
.then(() => true)
|
|
34
|
-
.catch(() => false)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
.catch(() => false);
|
|
33
|
+
if (exists) {
|
|
34
|
+
this.resolvedPackages[packageName] = dir;
|
|
35
|
+
return dir;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
this.resolvedPackages[packageName] = null;
|
|
39
|
+
return undefined;
|
|
41
40
|
}
|
|
42
41
|
async resolve(file) {
|
|
43
42
|
const resolvedFile = this.require.resolve(file);
|
|
44
43
|
return (await this.fileSystem.fileExists(resolvedFile)) ? resolvedFile : undefined;
|
|
45
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Copies an asset from a resolved package path to a destination.
|
|
47
|
+
* @param from - Source path relative to node_modules
|
|
48
|
+
* @param to - Destination path
|
|
49
|
+
* @throws Error if the source asset cannot be resolved
|
|
50
|
+
*/
|
|
46
51
|
async copy(from, to) {
|
|
47
52
|
const fromPath = await this.resolve(from);
|
|
48
|
-
if (
|
|
53
|
+
if (fromPath === undefined || fromPath === '') {
|
|
49
54
|
throw new Error(`Could not resolve source asset "${from}"`);
|
|
50
55
|
}
|
|
51
56
|
await this.fileSystem.fileCopy(fromPath, to);
|
|
52
57
|
}
|
|
53
58
|
async read(file) {
|
|
54
59
|
const fromPath = await this.resolve(file);
|
|
55
|
-
if (
|
|
60
|
+
if (fromPath === undefined || fromPath === '') {
|
|
56
61
|
throw new Error(`Could not resolve asset "${file}"`);
|
|
57
62
|
}
|
|
58
63
|
return this.fileSystem.fileRead(fromPath);
|
|
@@ -60,14 +65,15 @@ class NodeAssetLoader {
|
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
class NodeFileFinder {
|
|
68
|
+
globs;
|
|
63
69
|
constructor(globs = []) {
|
|
64
|
-
this.globs = [];
|
|
65
70
|
this.globs = globs.map(glob => path.resolve(glob));
|
|
66
71
|
}
|
|
67
72
|
async search(fileFound) {
|
|
68
|
-
|
|
73
|
+
const searchResults = await Promise.all(this.globs.map(async (glob) => this.searchGlob(glob, fileFound)));
|
|
74
|
+
await Promise.all(searchResults.flat());
|
|
69
75
|
}
|
|
70
|
-
searchGlob(glob, fileFound) {
|
|
76
|
+
async searchGlob(glob, fileFound) {
|
|
71
77
|
const scan = picomatch.scan(glob, { parts: true, tokens: true });
|
|
72
78
|
const pathBase = path.join(scan.prefix, scan.base);
|
|
73
79
|
const recursive = scan.maxDepth === Infinity;
|
|
@@ -99,8 +105,11 @@ class NodeFileFinder {
|
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
class NodeFileSystem {
|
|
108
|
+
static instance;
|
|
109
|
+
assetLoaderInstance;
|
|
110
|
+
constructor() { }
|
|
102
111
|
static init() {
|
|
103
|
-
if (
|
|
112
|
+
if (this.instance === undefined) {
|
|
104
113
|
this.instance = new NodeFileSystem();
|
|
105
114
|
}
|
|
106
115
|
return this.instance;
|
|
@@ -121,24 +130,16 @@ class NodeFileSystem {
|
|
|
121
130
|
return fs.readFile(this.resolve(file), 'utf8');
|
|
122
131
|
}
|
|
123
132
|
async fileWrite(file, content) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
catch (e) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
133
|
+
return fs
|
|
134
|
+
.writeFile(this.resolve(file), content, 'utf8')
|
|
135
|
+
.then(() => true)
|
|
136
|
+
.catch(() => false);
|
|
131
137
|
}
|
|
132
138
|
async fileCopy(from, to) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
catch (e) {
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
139
|
+
return fs
|
|
140
|
+
.copyFile(this.resolve(from), this.resolve(to))
|
|
141
|
+
.then(() => true)
|
|
142
|
+
.catch(() => false);
|
|
142
143
|
}
|
|
143
144
|
async fileExists(file) {
|
|
144
145
|
return fs
|
|
@@ -157,13 +158,10 @@ class NodeFileSystem {
|
|
|
157
158
|
return true;
|
|
158
159
|
}
|
|
159
160
|
async isDirectory(dir) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
catch (e) {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
161
|
+
return fs
|
|
162
|
+
.stat(this.resolve(dir))
|
|
163
|
+
.then(stats => stats.isDirectory())
|
|
164
|
+
.catch(() => false);
|
|
167
165
|
}
|
|
168
166
|
async directoryCopy(from, to) {
|
|
169
167
|
const fromDir = this.resolve(from);
|
|
@@ -175,16 +173,18 @@ class NodeFileSystem {
|
|
|
175
173
|
const res = await Promise.all(dirents.map(async (dirent) => {
|
|
176
174
|
const fromPath = path.join(fromDir, dirent.name);
|
|
177
175
|
const toPath = path.join(toDir, dirent.name);
|
|
178
|
-
return
|
|
176
|
+
return dirent.isDirectory()
|
|
179
177
|
? this.directoryCopy(fromPath, toPath)
|
|
180
178
|
: this.fileCopy(fromPath, toPath);
|
|
181
179
|
}));
|
|
182
|
-
return
|
|
180
|
+
return res.every(value => value === true);
|
|
183
181
|
}
|
|
184
182
|
}
|
|
185
|
-
function
|
|
183
|
+
function createNodeFileSystem() {
|
|
186
184
|
return NodeFileSystem.init();
|
|
187
185
|
}
|
|
186
|
+
/** @deprecated Use createNodeFileSystem instead */
|
|
187
|
+
const cerateNodeFileSystem = createNodeFileSystem;
|
|
188
188
|
|
|
189
|
-
export { NodeAssetLoader, NodeFileFinder, NodeFileSystem, cerateNodeFileSystem };
|
|
189
|
+
export { NodeAssetLoader, NodeFileFinder, NodeFileSystem, cerateNodeFileSystem, createNodeFileSystem };
|
|
190
190
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/NodeAssetLoader.ts","../src/NodeFileFinder.ts","../src/NodeFileSystem.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/NodeAssetLoader.ts","../src/NodeFileFinder.ts","../src/NodeFileSystem.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;;;MAMa,eAAe,CAAA;IAClB,g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YAAA,OAAO,KAAK,CAAA;SACb;AAED,QAAA,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AAElE,QAAA,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,GAAG,CAC3B,OAAO,CAAC,GAAG,CAAC,OAAM,MAAM,KAAG;AACzB,YAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;AAChD,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;YAE5C,OAAO,MAAM,CAAC,WAAW,EAAE;kBACvB,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC;kBACpC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;SACpC,CAAC,CACH,CAAA;AAED,QAAA,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,KAAK,IAAI,CAAC,CAAA;KAC1C;AACF,CAAA;SAEe,oBAAoB,GAAA;AAClC,IAAA,OAAO,cAAc,CAAC,IAAI,EAAE,CAAA;AAC9B,CAAC;AAED;AACO,MAAM,oBAAoB,GAAG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui-doc/node",
|
|
3
|
+
"version": "0.2.2",
|
|
3
4
|
"description": "Node implementations for UI-Doc.",
|
|
4
|
-
"
|
|
5
|
+
"author": "Maurice Busch",
|
|
5
6
|
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/gherrink/ui-doc/tree/master/packages/node#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/gherrink/ui-doc.git",
|
|
11
|
+
"directory": "packages/node"
|
|
12
|
+
},
|
|
13
|
+
"bugs": "https://github.com/gherrink/ui-doc/issues",
|
|
6
14
|
"keywords": [
|
|
7
15
|
"ui-doc",
|
|
8
16
|
"styleguide",
|
|
@@ -11,17 +19,7 @@
|
|
|
11
19
|
"generation",
|
|
12
20
|
"node"
|
|
13
21
|
],
|
|
14
|
-
"
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "https://github.com/gherrink/ui-doc",
|
|
17
|
-
"directory": "packages/node"
|
|
18
|
-
},
|
|
19
|
-
"author": "Maurice Busch",
|
|
20
|
-
"homepage": "https://github.com/gherrink/ui-doc/tree/master/packages/node#readme",
|
|
21
|
-
"bugs": "https://github.com/gherrink/ui-doc/issues",
|
|
22
|
-
"main": "./dist/index.cjs",
|
|
23
|
-
"module": "./dist/index.mjs",
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
22
|
+
"sideEffects": false,
|
|
25
23
|
"exports": {
|
|
26
24
|
".": {
|
|
27
25
|
"types": "./dist/index.d.ts",
|
|
@@ -29,20 +27,33 @@
|
|
|
29
27
|
"default": "./dist/index.cjs"
|
|
30
28
|
}
|
|
31
29
|
},
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
"main": "./dist/index.cjs",
|
|
31
|
+
"module": "./dist/index.mjs",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
35
33
|
"files": [
|
|
36
|
-
"dist",
|
|
37
34
|
"LICENSE.md",
|
|
38
|
-
"README.md"
|
|
35
|
+
"README.md",
|
|
36
|
+
"dist"
|
|
39
37
|
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=16.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "rollup -c",
|
|
43
|
+
"clean": "rm -rf dist",
|
|
44
|
+
"prebuild": "pnpm clean",
|
|
45
|
+
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
|
|
46
|
+
"prepublish": "pnpm build",
|
|
47
|
+
"release": "pnpm --workspace-root package:release $(pwd)",
|
|
48
|
+
"release:dry": "pnpm --workspace-root package:release-dry $(pwd)",
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"typecheck": "tsc --noEmit"
|
|
51
|
+
},
|
|
40
52
|
"publishConfig": {
|
|
41
53
|
"access": "public"
|
|
42
54
|
},
|
|
43
|
-
"sideEffects": false,
|
|
44
55
|
"peerDependencies": {
|
|
45
|
-
"@ui-doc/core": "
|
|
56
|
+
"@ui-doc/core": "workspace:>=0.3.0",
|
|
46
57
|
"node": "^16.0.0||^18.0.0||^20.0.0||^22.0.0"
|
|
47
58
|
},
|
|
48
59
|
"dependencies": {
|
|
@@ -51,14 +62,6 @@
|
|
|
51
62
|
"devDependencies": {
|
|
52
63
|
"@types/node": "^20.12.7",
|
|
53
64
|
"@types/picomatch": "^2.3.3",
|
|
54
|
-
"@ui-doc/core": "
|
|
55
|
-
},
|
|
56
|
-
"scripts": {
|
|
57
|
-
"build": "rollup -c",
|
|
58
|
-
"prebuild": "rm -rf dist dist",
|
|
59
|
-
"prepublish": "pnpm build",
|
|
60
|
-
"release": "pnpm --workspace-root package:release $(pwd)",
|
|
61
|
-
"release:dry": "pnpm --workspace-root package:release-dry $(pwd)",
|
|
62
|
-
"test": "jest"
|
|
65
|
+
"@ui-doc/core": "workspace:^"
|
|
63
66
|
}
|
|
64
|
-
}
|
|
67
|
+
}
|
package/LICENSE.md
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|