@tomei/finance 0.17.0 → 0.18.2-dev.1
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/.commitlintrc.json +23 -23
- package/CHANGELOG.md +17 -0
- package/LICENSE +21 -21
- package/MIGRATION.md +43 -0
- package/configs/config.js +348 -348
- package/dist/document/document.d.ts +3 -0
- package/dist/document/document.d.ts.map +1 -1
- package/dist/document/document.js +5 -0
- package/dist/document/document.js.map +1 -1
- package/dist/document/interfaces/document-attr.interface.d.ts +3 -1
- package/dist/document/interfaces/document-attr.interface.d.ts.map +1 -1
- package/dist/document/interfaces/document-attr.interface.js.map +1 -1
- package/dist/enum/index.d.ts +2 -1
- package/dist/enum/index.d.ts.map +1 -1
- package/dist/enum/index.js +3 -1
- package/dist/enum/index.js.map +1 -1
- package/dist/enum/posting-status.enum.d.ts +7 -0
- package/dist/enum/posting-status.enum.d.ts.map +1 -0
- package/dist/enum/posting-status.enum.js +11 -0
- package/dist/enum/posting-status.enum.js.map +1 -0
- package/dist/finance-company/finance-company.d.ts +7 -3
- package/dist/finance-company/finance-company.d.ts.map +1 -1
- package/dist/finance-company/finance-company.js +48 -16
- package/dist/finance-company/finance-company.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/models/document.entity.d.ts +3 -0
- package/dist/models/document.entity.d.ts.map +1 -1
- package/dist/models/document.entity.js +20 -0
- package/dist/models/document.entity.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/invoice-template/assets/css/style.css.map +12 -12
- package/invoice-template/assets/css/style.min.css +1 -1
- package/invoice-template/assets/img/arrow_bg.svg +11 -11
- package/invoice-template/assets/img/coffy_shop_img.svg +18 -18
- package/invoice-template/assets/img/logo_accent.svg +3 -3
- package/invoice-template/assets/img/logo_white.svg +4 -4
- package/invoice-template/assets/img/sign.svg +12 -12
- package/invoice-template/assets/img/tomei-logo.svg +9 -9
- package/invoice-template/assets/js/html2canvas.min.js +10379 -10379
- package/invoice-template/assets/js/jquery.min.js +1 -1
- package/invoice-template/assets/sass/common/_color_variable.scss +12 -12
- package/invoice-template/assets/sass/common/_typography.scss +178 -178
- package/invoice-template/assets/sass/style.scss +12 -12
- package/migrations/add-discount-collumn-to-document-related-table.js +90 -90
- package/migrations/finance-account-migration.js +97 -97
- package/migrations/finance-company-migration.js +29 -29
- package/migrations/finance-customer-migration.js +51 -51
- package/migrations/finance-document-item-migration.js +111 -111
- package/migrations/finance-document-migration.js +122 -122
- package/migrations/finance-document-tag-migration.js +46 -46
- package/migrations/finance-journal-entry-migration.js +59 -59
- package/migrations/finance-ledger-transaction-migration.js +89 -89
- package/migrations/finance-payment-item-migration.js +52 -52
- package/migrations/finance-payment-method-migration.js +31 -31
- package/migrations/finance-payment-method-type-migration.js +55 -55
- package/migrations/finance-payment-migration.js +96 -96
- package/migrations/finance-post-history-migration.js +45 -45
- package/migrations/finance-tag-group-migration.js +53 -53
- package/migrations/finance-tag-migration.js +63 -63
- package/migrations/finance-tax-migration.js +52 -52
- package/migrations/refactor-finance-document-migration.js +71 -71
- package/migrations/update-document-item.migration.js +87 -87
- package/package.json +81 -79
- package/receipt-template/default/assets/css/style.css +2629 -2629
- package/receipt-template/default/assets/css/style.css.map +12 -12
- package/receipt-template/default/assets/css/style.min.css +1 -1
- package/receipt-template/default/assets/img/arrow_bg.svg +11 -11
- package/receipt-template/default/assets/img/coffy_shop_img.svg +18 -18
- package/receipt-template/default/assets/img/logo.svg +4 -4
- package/receipt-template/default/assets/img/logo_accent.svg +3 -3
- package/receipt-template/default/assets/img/logo_white.svg +4 -4
- package/receipt-template/default/assets/img/sign.svg +12 -12
- package/receipt-template/default/assets/img/tomei-logo.svg +9 -9
- package/receipt-template/default/assets/js/html2canvas.min.js +10379 -10379
- package/receipt-template/default/assets/js/jquery.min.js +1 -1
- package/receipt-template/default/assets/js/main.js +48 -48
- package/receipt-template/default/assets/sass/common/_color_variable.scss +12 -12
- package/receipt-template/default/assets/sass/common/_invoice.scss +1801 -1801
- package/receipt-template/default/assets/sass/common/_normalize.scss +350 -350
- package/receipt-template/default/assets/sass/common/_typography.scss +178 -178
- package/receipt-template/default/assets/sass/style.scss +12 -12
- package/receipt-template/default/index.html +291 -291
- package/scripts/postinstall.js +300 -300
- package/dist/enum/quick-book-client-scopes.enum.d.ts +0 -13
- package/dist/enum/quick-book-client-scopes.enum.js +0 -19
- package/dist/enum/quick-book-client-scopes.enum.js.map +0 -1
package/scripts/postinstall.js
CHANGED
|
@@ -1,301 +1,301 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { execSync, spawn } = require('child_process');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const os = require('os');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Post-install script for @tomei/finance package
|
|
10
|
-
* Ensures Puppeteer and Chrome are properly configured for PDF generation
|
|
11
|
-
* Supports Linux, Windows, and macOS environments
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
console.log('🔧 Setting up @tomei/finance package...');
|
|
15
|
-
|
|
16
|
-
async function setupPuppeteer() {
|
|
17
|
-
try {
|
|
18
|
-
const platform = os.platform();
|
|
19
|
-
console.log(`📱 Detected platform: ${platform}`);
|
|
20
|
-
|
|
21
|
-
// Check if we're in a CI environment
|
|
22
|
-
const isCI = process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true' || process.env.GITLAB_CI === 'true';
|
|
23
|
-
if (isCI) {
|
|
24
|
-
console.log('🤖 CI environment detected. Skipping interactive Chrome setup.');
|
|
25
|
-
console.log('ℹ️ Chrome will be installed on first PDF generation attempt.');
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
console.log('📦 Checking Puppeteer Chrome installation...');
|
|
30
|
-
|
|
31
|
-
// Determine appropriate cache directory based on platform
|
|
32
|
-
const cacheDir = getCacheDirectory(platform);
|
|
33
|
-
console.log(` Cache directory: ${cacheDir}`);
|
|
34
|
-
|
|
35
|
-
// Check if Chrome is already installed
|
|
36
|
-
const chromeExists = await checkChromeInstallation(cacheDir, platform);
|
|
37
|
-
|
|
38
|
-
if (chromeExists) {
|
|
39
|
-
console.log('✅ Chrome is already installed and ready for PDF generation');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log('📥 Installing Chrome browser for PDF generation...');
|
|
44
|
-
|
|
45
|
-
// Install system dependencies first (Linux only, and only if we have permissions)
|
|
46
|
-
if (platform === 'linux') {
|
|
47
|
-
await installLinuxDependencies();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Install Chrome
|
|
51
|
-
await installChrome(cacheDir, platform);
|
|
52
|
-
|
|
53
|
-
console.log('✅ Puppeteer Chrome setup completed successfully!');
|
|
54
|
-
|
|
55
|
-
} catch (error) {
|
|
56
|
-
console.error('⚠️ Warning: Puppeteer setup encountered issues:', error.message);
|
|
57
|
-
console.log('');
|
|
58
|
-
console.log('📖 Manual setup instructions:');
|
|
59
|
-
console.log(' 1. Run: npx puppeteer browsers install chrome');
|
|
60
|
-
|
|
61
|
-
if (os.platform() === 'linux') {
|
|
62
|
-
console.log(' 2. Install dependencies: sudo apt-get install -y libxfixes3 libnss3 libatk-bridge2.0-0t64');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
console.log(' 3. Set environment: export PUPPETEER_CACHE_DIR=' + getCacheDirectory(os.platform()));
|
|
66
|
-
console.log('');
|
|
67
|
-
console.log('📄 PDF generation may not work until Chrome is properly installed.');
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function getCacheDirectory(platform) {
|
|
72
|
-
const userId = process.getuid ? process.getuid() : null;
|
|
73
|
-
const isRoot = userId === 0;
|
|
74
|
-
|
|
75
|
-
switch (platform) {
|
|
76
|
-
case 'win32':
|
|
77
|
-
return process.env.PUPPETEER_CACHE_DIR ||
|
|
78
|
-
path.join(process.env.USERPROFILE || process.env.HOME || os.tmpdir(), '.cache', 'puppeteer');
|
|
79
|
-
|
|
80
|
-
case 'darwin':
|
|
81
|
-
return process.env.PUPPETEER_CACHE_DIR ||
|
|
82
|
-
path.join(process.env.HOME || os.tmpdir(), '.cache', 'puppeteer');
|
|
83
|
-
|
|
84
|
-
case 'linux':
|
|
85
|
-
default:
|
|
86
|
-
if (isRoot) {
|
|
87
|
-
return process.env.PUPPETEER_CACHE_DIR || '/root/.cache/puppeteer';
|
|
88
|
-
} else {
|
|
89
|
-
return process.env.PUPPETEER_CACHE_DIR ||
|
|
90
|
-
path.join(process.env.HOME || os.tmpdir(), '.cache', 'puppeteer');
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async function checkChromeInstallation(cacheDir, platform) {
|
|
96
|
-
try {
|
|
97
|
-
// Check if cache directory exists
|
|
98
|
-
if (!fs.existsSync(cacheDir)) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Look for Chrome executable based on platform
|
|
103
|
-
let chromePaths = [];
|
|
104
|
-
|
|
105
|
-
if (platform === 'win32') {
|
|
106
|
-
// Windows Chrome paths
|
|
107
|
-
chromePaths = [
|
|
108
|
-
path.join(cacheDir, '**/chrome.exe'),
|
|
109
|
-
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
|
110
|
-
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
|
|
111
|
-
];
|
|
112
|
-
} else if (platform === 'darwin') {
|
|
113
|
-
// macOS Chrome paths
|
|
114
|
-
chromePaths = [
|
|
115
|
-
path.join(cacheDir, '**/chrome'),
|
|
116
|
-
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
|
117
|
-
];
|
|
118
|
-
} else {
|
|
119
|
-
// Linux Chrome paths
|
|
120
|
-
chromePaths = [
|
|
121
|
-
path.join(cacheDir, '**/chrome'),
|
|
122
|
-
'/usr/bin/google-chrome',
|
|
123
|
-
'/usr/bin/google-chrome-stable',
|
|
124
|
-
'/usr/bin/chromium-browser'
|
|
125
|
-
];
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Check each possible path
|
|
129
|
-
for (const chromePath of chromePaths) {
|
|
130
|
-
try {
|
|
131
|
-
if (chromePath.includes('**')) {
|
|
132
|
-
// Use find command for glob patterns
|
|
133
|
-
const findCommand = platform === 'win32'
|
|
134
|
-
? `dir "${cacheDir}" /s /b | findstr chrome.exe`
|
|
135
|
-
: `find "${cacheDir}" -name "chrome" -type f -executable 2>/dev/null | head -1`;
|
|
136
|
-
|
|
137
|
-
const result = execSync(findCommand, { encoding: 'utf8' }).trim();
|
|
138
|
-
if (result && fs.existsSync(result.split('\n')[0])) {
|
|
139
|
-
const foundPath = result.split('\n')[0];
|
|
140
|
-
console.log(` Found Chrome at: ${foundPath}`);
|
|
141
|
-
|
|
142
|
-
// Test if Chrome can start (with timeout)
|
|
143
|
-
if (await testChromeStartup(foundPath, platform)) {
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
// Direct path check
|
|
149
|
-
if (fs.existsSync(chromePath)) {
|
|
150
|
-
console.log(` Found Chrome at: ${chromePath}`);
|
|
151
|
-
|
|
152
|
-
// Test if Chrome can start
|
|
153
|
-
if (await testChromeStartup(chromePath, platform)) {
|
|
154
|
-
return true;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
} catch (e) {
|
|
159
|
-
// Continue checking other paths
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return false;
|
|
164
|
-
|
|
165
|
-
} catch (error) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
async function testChromeStartup(chromePath, platform) {
|
|
171
|
-
try {
|
|
172
|
-
const versionArg = platform === 'win32' ? '--version' : '--version --no-sandbox';
|
|
173
|
-
execSync(`"${chromePath}" ${versionArg}`, {
|
|
174
|
-
stdio: 'pipe',
|
|
175
|
-
timeout: 10000
|
|
176
|
-
});
|
|
177
|
-
console.log(` ✅ Chrome startup test successful`);
|
|
178
|
-
return true;
|
|
179
|
-
} catch (e) {
|
|
180
|
-
console.log(` ⚠️ Chrome found but startup test failed`);
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
async function installLinuxDependencies() {
|
|
186
|
-
try {
|
|
187
|
-
const userId = process.getuid ? process.getuid() : null;
|
|
188
|
-
const isRoot = userId === 0;
|
|
189
|
-
|
|
190
|
-
if (!isRoot) {
|
|
191
|
-
console.log(' ℹ️ Skipping system dependencies (not running as root)');
|
|
192
|
-
console.log(' 💡 If you encounter Chrome issues, run: sudo apt-get install -y libxfixes3 libnss3 libatk-bridge2.0-0t64');
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
console.log('📦 Installing Linux system dependencies...');
|
|
197
|
-
|
|
198
|
-
// Check if apt-get is available
|
|
199
|
-
try {
|
|
200
|
-
execSync('which apt-get', { stdio: 'pipe' });
|
|
201
|
-
} catch (e) {
|
|
202
|
-
console.log(' ℹ️ apt-get not found, skipping system dependencies');
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Install Chrome dependencies (with error handling for different Ubuntu versions)
|
|
207
|
-
const dependencies = [
|
|
208
|
-
'libxfixes3',
|
|
209
|
-
'libnss3',
|
|
210
|
-
'ca-certificates',
|
|
211
|
-
'fonts-liberation',
|
|
212
|
-
'xdg-utils'
|
|
213
|
-
];
|
|
214
|
-
|
|
215
|
-
// Try modern Ubuntu packages first, fallback to older ones
|
|
216
|
-
const modernDeps = [
|
|
217
|
-
'libatk-bridge2.0-0t64',
|
|
218
|
-
'libasound2t64',
|
|
219
|
-
'libatspi2.0-0t64',
|
|
220
|
-
'libgtk-3-0t64'
|
|
221
|
-
];
|
|
222
|
-
|
|
223
|
-
const fallbackDeps = [
|
|
224
|
-
'libatk-bridge2.0-0',
|
|
225
|
-
'libasound2',
|
|
226
|
-
'libatspi2.0-0',
|
|
227
|
-
'libgtk-3-0'
|
|
228
|
-
];
|
|
229
|
-
|
|
230
|
-
try {
|
|
231
|
-
// Try modern packages first
|
|
232
|
-
execSync(`apt-get update -qq && apt-get install -y ${dependencies.concat(modernDeps).join(' ')}`, {
|
|
233
|
-
stdio: 'pipe',
|
|
234
|
-
timeout: 120000
|
|
235
|
-
});
|
|
236
|
-
console.log(' ✅ Modern system dependencies installed');
|
|
237
|
-
} catch (e) {
|
|
238
|
-
try {
|
|
239
|
-
// Fallback to older packages
|
|
240
|
-
execSync(`apt-get install -y ${dependencies.concat(fallbackDeps).join(' ')}`, {
|
|
241
|
-
stdio: 'pipe',
|
|
242
|
-
timeout: 120000
|
|
243
|
-
});
|
|
244
|
-
console.log(' ✅ Fallback system dependencies installed');
|
|
245
|
-
} catch (e2) {
|
|
246
|
-
console.log(' ⚠️ Could not install some system dependencies');
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
} catch (error) {
|
|
251
|
-
console.log(' ⚠️ Could not install system dependencies:', error.message);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
async function installChrome(cacheDir, platform) {
|
|
256
|
-
try {
|
|
257
|
-
// Create cache directory
|
|
258
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
259
|
-
|
|
260
|
-
// Set environment for installation
|
|
261
|
-
const installEnv = {
|
|
262
|
-
...process.env,
|
|
263
|
-
PUPPETEER_CACHE_DIR: cacheDir
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
// Set HOME appropriately for different platforms
|
|
267
|
-
if (platform === 'linux') {
|
|
268
|
-
const userId = process.getuid ? process.getuid() : null;
|
|
269
|
-
const isRoot = userId === 0;
|
|
270
|
-
installEnv.HOME = isRoot ? '/root' : process.env.HOME;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
console.log(' Installing Chrome browser...');
|
|
274
|
-
|
|
275
|
-
// Install Chrome using Puppeteer with longer timeout
|
|
276
|
-
execSync('npx puppeteer browsers install chrome', {
|
|
277
|
-
stdio: 'pipe',
|
|
278
|
-
env: installEnv,
|
|
279
|
-
timeout: 300000 // 5 minutes timeout
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
// Verify installation
|
|
283
|
-
const chromeExists = await checkChromeInstallation(cacheDir, platform);
|
|
284
|
-
if (!chromeExists) {
|
|
285
|
-
throw new Error('Chrome installation verification failed');
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
console.log(' ✅ Chrome browser installed successfully');
|
|
289
|
-
|
|
290
|
-
} catch (error) {
|
|
291
|
-
throw new Error(`Chrome installation failed: ${error.message}`);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// Run setup
|
|
296
|
-
setupPuppeteer().then(() => {
|
|
297
|
-
console.log('🎉 @tomei/finance package setup complete!');
|
|
298
|
-
}).catch((error) => {
|
|
299
|
-
console.error('❌ Setup failed:', error.message);
|
|
300
|
-
process.exit(0); // Don't fail the npm install
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync, spawn } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Post-install script for @tomei/finance package
|
|
10
|
+
* Ensures Puppeteer and Chrome are properly configured for PDF generation
|
|
11
|
+
* Supports Linux, Windows, and macOS environments
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
console.log('🔧 Setting up @tomei/finance package...');
|
|
15
|
+
|
|
16
|
+
async function setupPuppeteer() {
|
|
17
|
+
try {
|
|
18
|
+
const platform = os.platform();
|
|
19
|
+
console.log(`📱 Detected platform: ${platform}`);
|
|
20
|
+
|
|
21
|
+
// Check if we're in a CI environment
|
|
22
|
+
const isCI = process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true' || process.env.GITLAB_CI === 'true';
|
|
23
|
+
if (isCI) {
|
|
24
|
+
console.log('🤖 CI environment detected. Skipping interactive Chrome setup.');
|
|
25
|
+
console.log('ℹ️ Chrome will be installed on first PDF generation attempt.');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log('📦 Checking Puppeteer Chrome installation...');
|
|
30
|
+
|
|
31
|
+
// Determine appropriate cache directory based on platform
|
|
32
|
+
const cacheDir = getCacheDirectory(platform);
|
|
33
|
+
console.log(` Cache directory: ${cacheDir}`);
|
|
34
|
+
|
|
35
|
+
// Check if Chrome is already installed
|
|
36
|
+
const chromeExists = await checkChromeInstallation(cacheDir, platform);
|
|
37
|
+
|
|
38
|
+
if (chromeExists) {
|
|
39
|
+
console.log('✅ Chrome is already installed and ready for PDF generation');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log('📥 Installing Chrome browser for PDF generation...');
|
|
44
|
+
|
|
45
|
+
// Install system dependencies first (Linux only, and only if we have permissions)
|
|
46
|
+
if (platform === 'linux') {
|
|
47
|
+
await installLinuxDependencies();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Install Chrome
|
|
51
|
+
await installChrome(cacheDir, platform);
|
|
52
|
+
|
|
53
|
+
console.log('✅ Puppeteer Chrome setup completed successfully!');
|
|
54
|
+
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('⚠️ Warning: Puppeteer setup encountered issues:', error.message);
|
|
57
|
+
console.log('');
|
|
58
|
+
console.log('📖 Manual setup instructions:');
|
|
59
|
+
console.log(' 1. Run: npx puppeteer browsers install chrome');
|
|
60
|
+
|
|
61
|
+
if (os.platform() === 'linux') {
|
|
62
|
+
console.log(' 2. Install dependencies: sudo apt-get install -y libxfixes3 libnss3 libatk-bridge2.0-0t64');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
console.log(' 3. Set environment: export PUPPETEER_CACHE_DIR=' + getCacheDirectory(os.platform()));
|
|
66
|
+
console.log('');
|
|
67
|
+
console.log('📄 PDF generation may not work until Chrome is properly installed.');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getCacheDirectory(platform) {
|
|
72
|
+
const userId = process.getuid ? process.getuid() : null;
|
|
73
|
+
const isRoot = userId === 0;
|
|
74
|
+
|
|
75
|
+
switch (platform) {
|
|
76
|
+
case 'win32':
|
|
77
|
+
return process.env.PUPPETEER_CACHE_DIR ||
|
|
78
|
+
path.join(process.env.USERPROFILE || process.env.HOME || os.tmpdir(), '.cache', 'puppeteer');
|
|
79
|
+
|
|
80
|
+
case 'darwin':
|
|
81
|
+
return process.env.PUPPETEER_CACHE_DIR ||
|
|
82
|
+
path.join(process.env.HOME || os.tmpdir(), '.cache', 'puppeteer');
|
|
83
|
+
|
|
84
|
+
case 'linux':
|
|
85
|
+
default:
|
|
86
|
+
if (isRoot) {
|
|
87
|
+
return process.env.PUPPETEER_CACHE_DIR || '/root/.cache/puppeteer';
|
|
88
|
+
} else {
|
|
89
|
+
return process.env.PUPPETEER_CACHE_DIR ||
|
|
90
|
+
path.join(process.env.HOME || os.tmpdir(), '.cache', 'puppeteer');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function checkChromeInstallation(cacheDir, platform) {
|
|
96
|
+
try {
|
|
97
|
+
// Check if cache directory exists
|
|
98
|
+
if (!fs.existsSync(cacheDir)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Look for Chrome executable based on platform
|
|
103
|
+
let chromePaths = [];
|
|
104
|
+
|
|
105
|
+
if (platform === 'win32') {
|
|
106
|
+
// Windows Chrome paths
|
|
107
|
+
chromePaths = [
|
|
108
|
+
path.join(cacheDir, '**/chrome.exe'),
|
|
109
|
+
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
|
110
|
+
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe'
|
|
111
|
+
];
|
|
112
|
+
} else if (platform === 'darwin') {
|
|
113
|
+
// macOS Chrome paths
|
|
114
|
+
chromePaths = [
|
|
115
|
+
path.join(cacheDir, '**/chrome'),
|
|
116
|
+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
|
|
117
|
+
];
|
|
118
|
+
} else {
|
|
119
|
+
// Linux Chrome paths
|
|
120
|
+
chromePaths = [
|
|
121
|
+
path.join(cacheDir, '**/chrome'),
|
|
122
|
+
'/usr/bin/google-chrome',
|
|
123
|
+
'/usr/bin/google-chrome-stable',
|
|
124
|
+
'/usr/bin/chromium-browser'
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Check each possible path
|
|
129
|
+
for (const chromePath of chromePaths) {
|
|
130
|
+
try {
|
|
131
|
+
if (chromePath.includes('**')) {
|
|
132
|
+
// Use find command for glob patterns
|
|
133
|
+
const findCommand = platform === 'win32'
|
|
134
|
+
? `dir "${cacheDir}" /s /b | findstr chrome.exe`
|
|
135
|
+
: `find "${cacheDir}" -name "chrome" -type f -executable 2>/dev/null | head -1`;
|
|
136
|
+
|
|
137
|
+
const result = execSync(findCommand, { encoding: 'utf8' }).trim();
|
|
138
|
+
if (result && fs.existsSync(result.split('\n')[0])) {
|
|
139
|
+
const foundPath = result.split('\n')[0];
|
|
140
|
+
console.log(` Found Chrome at: ${foundPath}`);
|
|
141
|
+
|
|
142
|
+
// Test if Chrome can start (with timeout)
|
|
143
|
+
if (await testChromeStartup(foundPath, platform)) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
// Direct path check
|
|
149
|
+
if (fs.existsSync(chromePath)) {
|
|
150
|
+
console.log(` Found Chrome at: ${chromePath}`);
|
|
151
|
+
|
|
152
|
+
// Test if Chrome can start
|
|
153
|
+
if (await testChromeStartup(chromePath, platform)) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} catch (e) {
|
|
159
|
+
// Continue checking other paths
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return false;
|
|
164
|
+
|
|
165
|
+
} catch (error) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function testChromeStartup(chromePath, platform) {
|
|
171
|
+
try {
|
|
172
|
+
const versionArg = platform === 'win32' ? '--version' : '--version --no-sandbox';
|
|
173
|
+
execSync(`"${chromePath}" ${versionArg}`, {
|
|
174
|
+
stdio: 'pipe',
|
|
175
|
+
timeout: 10000
|
|
176
|
+
});
|
|
177
|
+
console.log(` ✅ Chrome startup test successful`);
|
|
178
|
+
return true;
|
|
179
|
+
} catch (e) {
|
|
180
|
+
console.log(` ⚠️ Chrome found but startup test failed`);
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function installLinuxDependencies() {
|
|
186
|
+
try {
|
|
187
|
+
const userId = process.getuid ? process.getuid() : null;
|
|
188
|
+
const isRoot = userId === 0;
|
|
189
|
+
|
|
190
|
+
if (!isRoot) {
|
|
191
|
+
console.log(' ℹ️ Skipping system dependencies (not running as root)');
|
|
192
|
+
console.log(' 💡 If you encounter Chrome issues, run: sudo apt-get install -y libxfixes3 libnss3 libatk-bridge2.0-0t64');
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
console.log('📦 Installing Linux system dependencies...');
|
|
197
|
+
|
|
198
|
+
// Check if apt-get is available
|
|
199
|
+
try {
|
|
200
|
+
execSync('which apt-get', { stdio: 'pipe' });
|
|
201
|
+
} catch (e) {
|
|
202
|
+
console.log(' ℹ️ apt-get not found, skipping system dependencies');
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Install Chrome dependencies (with error handling for different Ubuntu versions)
|
|
207
|
+
const dependencies = [
|
|
208
|
+
'libxfixes3',
|
|
209
|
+
'libnss3',
|
|
210
|
+
'ca-certificates',
|
|
211
|
+
'fonts-liberation',
|
|
212
|
+
'xdg-utils'
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
// Try modern Ubuntu packages first, fallback to older ones
|
|
216
|
+
const modernDeps = [
|
|
217
|
+
'libatk-bridge2.0-0t64',
|
|
218
|
+
'libasound2t64',
|
|
219
|
+
'libatspi2.0-0t64',
|
|
220
|
+
'libgtk-3-0t64'
|
|
221
|
+
];
|
|
222
|
+
|
|
223
|
+
const fallbackDeps = [
|
|
224
|
+
'libatk-bridge2.0-0',
|
|
225
|
+
'libasound2',
|
|
226
|
+
'libatspi2.0-0',
|
|
227
|
+
'libgtk-3-0'
|
|
228
|
+
];
|
|
229
|
+
|
|
230
|
+
try {
|
|
231
|
+
// Try modern packages first
|
|
232
|
+
execSync(`apt-get update -qq && apt-get install -y ${dependencies.concat(modernDeps).join(' ')}`, {
|
|
233
|
+
stdio: 'pipe',
|
|
234
|
+
timeout: 120000
|
|
235
|
+
});
|
|
236
|
+
console.log(' ✅ Modern system dependencies installed');
|
|
237
|
+
} catch (e) {
|
|
238
|
+
try {
|
|
239
|
+
// Fallback to older packages
|
|
240
|
+
execSync(`apt-get install -y ${dependencies.concat(fallbackDeps).join(' ')}`, {
|
|
241
|
+
stdio: 'pipe',
|
|
242
|
+
timeout: 120000
|
|
243
|
+
});
|
|
244
|
+
console.log(' ✅ Fallback system dependencies installed');
|
|
245
|
+
} catch (e2) {
|
|
246
|
+
console.log(' ⚠️ Could not install some system dependencies');
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
} catch (error) {
|
|
251
|
+
console.log(' ⚠️ Could not install system dependencies:', error.message);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async function installChrome(cacheDir, platform) {
|
|
256
|
+
try {
|
|
257
|
+
// Create cache directory
|
|
258
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
259
|
+
|
|
260
|
+
// Set environment for installation
|
|
261
|
+
const installEnv = {
|
|
262
|
+
...process.env,
|
|
263
|
+
PUPPETEER_CACHE_DIR: cacheDir
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
// Set HOME appropriately for different platforms
|
|
267
|
+
if (platform === 'linux') {
|
|
268
|
+
const userId = process.getuid ? process.getuid() : null;
|
|
269
|
+
const isRoot = userId === 0;
|
|
270
|
+
installEnv.HOME = isRoot ? '/root' : process.env.HOME;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
console.log(' Installing Chrome browser...');
|
|
274
|
+
|
|
275
|
+
// Install Chrome using Puppeteer with longer timeout
|
|
276
|
+
execSync('npx puppeteer browsers install chrome', {
|
|
277
|
+
stdio: 'pipe',
|
|
278
|
+
env: installEnv,
|
|
279
|
+
timeout: 300000 // 5 minutes timeout
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
// Verify installation
|
|
283
|
+
const chromeExists = await checkChromeInstallation(cacheDir, platform);
|
|
284
|
+
if (!chromeExists) {
|
|
285
|
+
throw new Error('Chrome installation verification failed');
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
console.log(' ✅ Chrome browser installed successfully');
|
|
289
|
+
|
|
290
|
+
} catch (error) {
|
|
291
|
+
throw new Error(`Chrome installation failed: ${error.message}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Run setup
|
|
296
|
+
setupPuppeteer().then(() => {
|
|
297
|
+
console.log('🎉 @tomei/finance package setup complete!');
|
|
298
|
+
}).catch((error) => {
|
|
299
|
+
console.error('❌ Setup failed:', error.message);
|
|
300
|
+
process.exit(0); // Don't fail the npm install
|
|
301
301
|
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClientScopes = void 0;
|
|
4
|
-
const OAuthClient = require("intuit-oauth");
|
|
5
|
-
var ClientScopes;
|
|
6
|
-
(function (ClientScopes) {
|
|
7
|
-
ClientScopes[ClientScopes["ACCOUNTING"] = OAuthClient.scopes.Accounting] = "ACCOUNTING";
|
|
8
|
-
ClientScopes[ClientScopes["PAYMENT"] = OAuthClient.scopes.Payment] = "PAYMENT";
|
|
9
|
-
ClientScopes[ClientScopes["PAYROLL"] = OAuthClient.scopes.Payroll] = "PAYROLL";
|
|
10
|
-
ClientScopes[ClientScopes["TIMETRACKING"] = OAuthClient.scopes.TimeTracking] = "TIMETRACKING";
|
|
11
|
-
ClientScopes[ClientScopes["BENEFITS"] = OAuthClient.scopes.Benefits] = "BENEFITS";
|
|
12
|
-
ClientScopes[ClientScopes["PROFILE"] = OAuthClient.scopes.Profile] = "PROFILE";
|
|
13
|
-
ClientScopes[ClientScopes["EMAIL"] = OAuthClient.scopes.Email] = "EMAIL";
|
|
14
|
-
ClientScopes[ClientScopes["PHONE"] = OAuthClient.scopes.Phone] = "PHONE";
|
|
15
|
-
ClientScopes[ClientScopes["ADDRESS"] = OAuthClient.scopes.Address] = "ADDRESS";
|
|
16
|
-
ClientScopes[ClientScopes["OPENID"] = OAuthClient.scopes.OpenId] = "OPENID";
|
|
17
|
-
ClientScopes[ClientScopes["INTUIT_NAME"] = OAuthClient.scopes.Intuit_name] = "INTUIT_NAME";
|
|
18
|
-
})(ClientScopes || (exports.ClientScopes = ClientScopes = {}));
|
|
19
|
-
//# sourceMappingURL=quick-book-client-scopes.enum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quick-book-client-scopes.enum.js","sourceRoot":"","sources":["../../src/enum/quick-book-client-scopes.enum.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,IAAY,YAYX;AAZD,WAAY,YAAY;IACtB,0CAAa,WAAW,CAAC,MAAM,CAAC,UAAU,gBAAA,CAAA;IAC1C,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,4CAAe,WAAW,CAAC,MAAM,CAAC,YAAY,kBAAA,CAAA;IAC9C,wCAAW,WAAW,CAAC,MAAM,CAAC,QAAQ,cAAA,CAAA;IACtC,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,qCAAQ,WAAW,CAAC,MAAM,CAAC,KAAK,WAAA,CAAA;IAChC,qCAAQ,WAAW,CAAC,MAAM,CAAC,KAAK,WAAA,CAAA;IAChC,uCAAU,WAAW,CAAC,MAAM,CAAC,OAAO,aAAA,CAAA;IACpC,sCAAS,WAAW,CAAC,MAAM,CAAC,MAAM,YAAA,CAAA;IAClC,2CAAc,WAAW,CAAC,MAAM,CAAC,WAAW,iBAAA,CAAA;AAC9C,CAAC,EAZW,YAAY,4BAAZ,YAAY,QAYvB"}
|