@fgv/ts-res-browser-cli 5.0.0-3 → 5.0.0-31

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.
Files changed (38) hide show
  1. package/README.md +35 -11
  2. package/eslint.config.js +16 -0
  3. package/lib/cli.d.ts +0 -4
  4. package/lib/cli.js +8 -17
  5. package/lib/index.d.ts +1 -1
  6. package/lib/index.js +1 -1
  7. package/lib/options.d.ts +16 -0
  8. package/lib/simpleBrowserLauncher.d.ts +32 -0
  9. package/lib/{browserLauncher.js → simpleBrowserLauncher.js} +53 -162
  10. package/lib/zipArchiver.d.ts +5 -17
  11. package/lib/zipArchiver.js +11 -72
  12. package/package.json +13 -13
  13. package/.rush/temp/6fdce6325ccacda5ae840a289f20e286e54e4f4b.tar.log +0 -32
  14. package/.rush/temp/chunked-rush-logs/ts-res-browser-cli.build.chunks.jsonl +0 -5
  15. package/.rush/temp/operation/build/all.log +0 -5
  16. package/.rush/temp/operation/build/log-chunks.jsonl +0 -5
  17. package/.rush/temp/operation/build/state.json +0 -3
  18. package/.rush/temp/shrinkwrap-deps.json +0 -651
  19. package/config/rig.json +0 -16
  20. package/lib/browserLauncher.d.ts +0 -57
  21. package/lib/browserLauncher.d.ts.map +0 -1
  22. package/lib/browserLauncher.js.map +0 -1
  23. package/lib/cli.d.ts.map +0 -1
  24. package/lib/cli.js.map +0 -1
  25. package/lib/index.d.ts.map +0 -1
  26. package/lib/index.js.map +0 -1
  27. package/lib/options.d.ts.map +0 -1
  28. package/lib/options.js.map +0 -1
  29. package/lib/zipArchiver.d.ts.map +0 -1
  30. package/lib/zipArchiver.js.map +0 -1
  31. package/rush-logs/ts-res-browser-cli.build.cache.log +0 -3
  32. package/rush-logs/ts-res-browser-cli.build.log +0 -5
  33. package/src/browserLauncher.ts +0 -406
  34. package/src/cli.ts +0 -423
  35. package/src/index.ts +0 -26
  36. package/src/options.ts +0 -133
  37. package/src/zipArchiver.ts +0 -153
  38. package/tsconfig.json +0 -7
@@ -1,153 +0,0 @@
1
- import * as archiver from 'archiver';
2
- import * as fs from 'fs';
3
- import * as path from 'path';
4
- import * as os from 'os';
5
- import { Result, succeed, fail } from '@fgv/ts-utils';
6
-
7
- export interface ZipArchiveOptions {
8
- input?: string;
9
- config?: string;
10
- outputDir?: string;
11
- }
12
-
13
- export interface ZipArchiveResult {
14
- zipPath: string;
15
- manifest: ZipManifest;
16
- }
17
-
18
- export interface ZipManifest {
19
- timestamp: string;
20
- input?: {
21
- type: 'file' | 'directory';
22
- originalPath: string;
23
- archivePath: string;
24
- };
25
- config?: {
26
- type: 'file';
27
- originalPath: string;
28
- archivePath: string;
29
- };
30
- }
31
-
32
- export class ZipArchiver {
33
- /**
34
- * Create a ZIP archive containing the specified input and config files/directories
35
- */
36
- async createArchive(options: ZipArchiveOptions): Promise<Result<ZipArchiveResult>> {
37
- try {
38
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
39
- const outputDir = options.outputDir || path.join(os.homedir(), 'Downloads');
40
- const zipFileName = `ts-res-bundle-${timestamp}.zip`;
41
- const zipPath = path.join(outputDir, zipFileName);
42
-
43
- // Ensure output directory exists
44
- if (!fs.existsSync(outputDir)) {
45
- fs.mkdirSync(outputDir, { recursive: true });
46
- }
47
-
48
- const output = fs.createWriteStream(zipPath);
49
- const archive = archiver.create('zip', {
50
- zlib: { level: 6 } // Good compression level
51
- });
52
-
53
- // Create manifest
54
- const manifest: ZipManifest = {
55
- timestamp: new Date().toISOString()
56
- };
57
-
58
- // Promise to handle async archiving
59
- const archivePromise = new Promise<void>((resolve, reject) => {
60
- output.on('close', () => {
61
- resolve();
62
- });
63
-
64
- output.on('error', (err: Error) => {
65
- reject(err);
66
- });
67
-
68
- archive.on('error', (err: Error) => {
69
- reject(err);
70
- });
71
- });
72
-
73
- // Pipe archive data to the file
74
- archive.pipe(output);
75
-
76
- // Add input files/directory
77
- if (options.input) {
78
- const inputPath = path.resolve(options.input);
79
-
80
- if (!fs.existsSync(inputPath)) {
81
- return fail(`Input path does not exist: ${inputPath}`);
82
- }
83
-
84
- const stats = fs.statSync(inputPath);
85
- if (stats.isDirectory()) {
86
- // Add entire directory recursively, preserving structure
87
- const dirName = path.basename(inputPath);
88
- archive.directory(inputPath, `input/${dirName}`);
89
- manifest.input = {
90
- type: 'directory',
91
- originalPath: inputPath,
92
- archivePath: `input/${dirName}`
93
- };
94
- } else if (stats.isFile()) {
95
- // Add single file
96
- const fileName = path.basename(inputPath);
97
- archive.file(inputPath, { name: `input/${fileName}` });
98
- manifest.input = {
99
- type: 'file',
100
- originalPath: inputPath,
101
- archivePath: `input/${fileName}`
102
- };
103
- }
104
- }
105
-
106
- // Add config file
107
- if (options.config) {
108
- const configPath = path.resolve(options.config);
109
-
110
- if (!fs.existsSync(configPath)) {
111
- return fail(`Config file does not exist: ${configPath}`);
112
- }
113
-
114
- const stats = fs.statSync(configPath);
115
- if (!stats.isFile()) {
116
- return fail(`Config path must be a file: ${configPath}`);
117
- }
118
-
119
- const fileName = path.basename(configPath);
120
- archive.file(configPath, { name: `config/${fileName}` });
121
- manifest.config = {
122
- type: 'file',
123
- originalPath: configPath,
124
- archivePath: `config/${fileName}`
125
- };
126
- }
127
-
128
- // Add manifest
129
- archive.append(JSON.stringify(manifest, null, 2), { name: 'manifest.json' });
130
-
131
- // Finalize the archive
132
- await archive.finalize();
133
- await archivePromise;
134
-
135
- return succeed({
136
- zipPath,
137
- manifest
138
- });
139
- } catch (error) {
140
- return fail(`Failed to create ZIP archive: ${error instanceof Error ? error.message : String(error)}`);
141
- }
142
- }
143
-
144
- /**
145
- * Get the default downloads directory path
146
- */
147
- getDefaultDownloadsDir(): string {
148
- return path.join(os.homedir(), 'Downloads');
149
- }
150
- }
151
-
152
- // Export singleton instance
153
- export const zipArchiver = new ZipArchiver();
package/tsconfig.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "./node_modules/@rushstack/heft-node-rig/profiles/default/tsconfig-base.json",
3
- "compilerOptions": {
4
- "types": ["node"],
5
- "incremental": false
6
- }
7
- }