@flowershow/publish 1.1.1 → 1.1.3
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/LICENSE +661 -0
- package/README.md +6 -8
- package/dist/cli.js +43 -41
- package/dist/cli.js.map +1 -1
- package/dist/lib/api-client.d.ts +3 -3
- package/dist/lib/api-client.js +27 -27
- package/dist/lib/auth.js +28 -28
- package/dist/lib/commands/auth-login.d.ts.map +1 -1
- package/dist/lib/commands/auth-login.js +30 -27
- package/dist/lib/commands/auth-login.js.map +1 -1
- package/dist/lib/commands/auth-logout.d.ts.map +1 -1
- package/dist/lib/commands/auth-logout.js +17 -14
- package/dist/lib/commands/auth-logout.js.map +1 -1
- package/dist/lib/commands/auth-status.d.ts.map +1 -1
- package/dist/lib/commands/auth-status.js +22 -19
- package/dist/lib/commands/auth-status.js.map +1 -1
- package/dist/lib/commands/delete.js +21 -21
- package/dist/lib/commands/list.js +17 -17
- package/dist/lib/commands/publish.js +31 -31
- package/dist/lib/commands/sync.js +35 -35
- package/dist/lib/const.d.ts +1 -1
- package/dist/lib/const.d.ts.map +1 -1
- package/dist/lib/const.js +6 -5
- package/dist/lib/const.js.map +1 -1
- package/dist/lib/files.js +33 -33
- package/dist/lib/telemetry.d.ts.map +1 -1
- package/dist/lib/telemetry.js +14 -14
- package/dist/lib/telemetry.js.map +1 -1
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +14 -14
- package/dist/package.json +2 -2
- package/package.json +2 -2
package/dist/lib/files.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { readFileSync, statSync, readdirSync, existsSync } from
|
|
2
|
-
import { join, basename, extname, relative, sep } from
|
|
3
|
-
import { createHash } from
|
|
4
|
-
import ignore from
|
|
1
|
+
import { readFileSync, statSync, readdirSync, existsSync } from 'fs';
|
|
2
|
+
import { join, basename, extname, relative, sep } from 'path';
|
|
3
|
+
import { createHash } from 'crypto';
|
|
4
|
+
import ignore from 'ignore';
|
|
5
5
|
const DEFAULT_IGNORE_PATTERNS = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
'.git/',
|
|
7
|
+
'.gitignore',
|
|
8
|
+
'node_modules/',
|
|
9
|
+
'.DS_Store',
|
|
10
|
+
'Thumbs.db',
|
|
11
|
+
'.env',
|
|
12
|
+
'.env.*',
|
|
13
|
+
'!.env.example',
|
|
14
|
+
'*.log',
|
|
15
|
+
'.cache/',
|
|
16
|
+
'dist/',
|
|
17
|
+
'build/',
|
|
18
|
+
'.next/',
|
|
19
|
+
'.vercel/',
|
|
20
|
+
'.turbo/',
|
|
21
|
+
'coverage/',
|
|
22
|
+
'.nyc_output/',
|
|
23
23
|
];
|
|
24
24
|
function loadGitignore(baseDir) {
|
|
25
25
|
const ig = ignore();
|
|
26
26
|
ig.add(DEFAULT_IGNORE_PATTERNS);
|
|
27
|
-
const gitignorePath = join(baseDir,
|
|
27
|
+
const gitignorePath = join(baseDir, '.gitignore');
|
|
28
28
|
if (existsSync(gitignorePath)) {
|
|
29
29
|
try {
|
|
30
|
-
const gitignoreContent = readFileSync(gitignorePath,
|
|
30
|
+
const gitignoreContent = readFileSync(gitignorePath, 'utf-8');
|
|
31
31
|
ig.add(gitignoreContent);
|
|
32
32
|
}
|
|
33
33
|
catch (error) {
|
|
@@ -37,18 +37,18 @@ function loadGitignore(baseDir) {
|
|
|
37
37
|
return ig;
|
|
38
38
|
}
|
|
39
39
|
function shouldIncludeFile(filePath, ig) {
|
|
40
|
-
const normalizedPath = filePath.split(sep).join(
|
|
40
|
+
const normalizedPath = filePath.split(sep).join('/');
|
|
41
41
|
return !ig.ignores(normalizedPath);
|
|
42
42
|
}
|
|
43
43
|
function calculateSha(content) {
|
|
44
|
-
return createHash(
|
|
44
|
+
return createHash('sha1').update(content).digest('hex');
|
|
45
45
|
}
|
|
46
46
|
function getExtension(filePath) {
|
|
47
47
|
const ext = extname(filePath);
|
|
48
|
-
return ext ? ext.slice(1).toLowerCase() :
|
|
48
|
+
return ext ? ext.slice(1).toLowerCase() : '';
|
|
49
49
|
}
|
|
50
50
|
function normalizePath(path) {
|
|
51
|
-
return path.split(sep).join(
|
|
51
|
+
return path.split(sep).join('/');
|
|
52
52
|
}
|
|
53
53
|
function scanDirectory(dirPath, baseDir = dirPath) {
|
|
54
54
|
const files = [];
|
|
@@ -75,7 +75,7 @@ function scanDirectory(dirPath, baseDir = dirPath) {
|
|
|
75
75
|
export function discoverFiles(inputPaths) {
|
|
76
76
|
const paths = Array.isArray(inputPaths) ? inputPaths : [inputPaths];
|
|
77
77
|
if (paths.length === 0) {
|
|
78
|
-
throw new Error(
|
|
78
|
+
throw new Error('No paths provided');
|
|
79
79
|
}
|
|
80
80
|
const allFiles = [];
|
|
81
81
|
let projectName = null;
|
|
@@ -134,21 +134,21 @@ export function discoverFiles(inputPaths) {
|
|
|
134
134
|
}
|
|
135
135
|
export function getProjectName(files) {
|
|
136
136
|
if (files.length === 0) {
|
|
137
|
-
throw new Error(
|
|
137
|
+
throw new Error('No files discovered');
|
|
138
138
|
}
|
|
139
139
|
const projectName = files[0]?.projectName;
|
|
140
140
|
if (!projectName) {
|
|
141
|
-
throw new Error(
|
|
141
|
+
throw new Error('Project name not found in files');
|
|
142
142
|
}
|
|
143
143
|
return projectName;
|
|
144
144
|
}
|
|
145
145
|
export function validateFiles(files) {
|
|
146
146
|
if (files.length === 0) {
|
|
147
|
-
throw new Error(
|
|
147
|
+
throw new Error('No files found to publish');
|
|
148
148
|
}
|
|
149
|
-
const hasMarkdownOrHtml = files.some((f) => [
|
|
149
|
+
const hasMarkdownOrHtml = files.some((f) => ['md', 'mdx', 'html'].includes(f.extension));
|
|
150
150
|
if (!hasMarkdownOrHtml) {
|
|
151
|
-
console.warn(
|
|
151
|
+
console.warn('Warning: No markdown or html files found. The site will be empty.');
|
|
152
152
|
}
|
|
153
153
|
return true;
|
|
154
154
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../lib/telemetry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../lib/telemetry.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,WAAW,QAAsB,CAAC;AA8C/C,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAiBD,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,IAAI,CAKN;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAKpD"}
|
package/dist/lib/telemetry.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { homedir } from
|
|
2
|
-
import { join } from
|
|
3
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync
|
|
4
|
-
import { randomUUID } from
|
|
5
|
-
import { PostHog } from
|
|
6
|
-
import packageJson from
|
|
7
|
-
import { POSTHOG_API_KEY, POSTHOG_HOST } from
|
|
1
|
+
import { homedir } from 'os';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
|
4
|
+
import { randomUUID } from 'crypto';
|
|
5
|
+
import { PostHog } from 'posthog-node';
|
|
6
|
+
import packageJson from '../package.json' with { type: 'json' };
|
|
7
|
+
import { POSTHOG_API_KEY, POSTHOG_HOST } from './const.js';
|
|
8
8
|
export const CLI_VERSION = packageJson.version;
|
|
9
|
-
const CONFIG_DIR = join(homedir(),
|
|
10
|
-
const CONFIG_FILE = join(CONFIG_DIR,
|
|
9
|
+
const CONFIG_DIR = join(homedir(), '.flowershow');
|
|
10
|
+
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
11
11
|
function readConfig() {
|
|
12
12
|
if (!existsSync(CONFIG_FILE))
|
|
13
13
|
return {};
|
|
14
14
|
try {
|
|
15
|
-
return JSON.parse(readFileSync(CONFIG_FILE,
|
|
15
|
+
return JSON.parse(readFileSync(CONFIG_FILE, 'utf-8'));
|
|
16
16
|
}
|
|
17
17
|
catch {
|
|
18
18
|
return {};
|
|
@@ -22,7 +22,7 @@ function writeConfig(config) {
|
|
|
22
22
|
if (!existsSync(CONFIG_DIR)) {
|
|
23
23
|
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
24
24
|
}
|
|
25
|
-
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2),
|
|
25
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf-8');
|
|
26
26
|
}
|
|
27
27
|
function getOrCreateDistinctId() {
|
|
28
28
|
const config = readConfig();
|
|
@@ -36,12 +36,12 @@ function showNoticeIfNeeded() {
|
|
|
36
36
|
const config = readConfig();
|
|
37
37
|
if (config.telemetryNoticeShown)
|
|
38
38
|
return;
|
|
39
|
-
console.log(
|
|
40
|
-
console.log(
|
|
39
|
+
console.log('\nTelemetry Notice: Flowershow CLI collects anonymous usage data to improve the product.');
|
|
40
|
+
console.log('To opt out, set the FLOWERSHOW_TELEMETRY_DISABLED=1 environment variable.\n');
|
|
41
41
|
writeConfig({ ...config, telemetryNoticeShown: true });
|
|
42
42
|
}
|
|
43
43
|
export function isEnabled() {
|
|
44
|
-
return !process.env[
|
|
44
|
+
return !process.env['FLOWERSHOW_TELEMETRY_DISABLED'];
|
|
45
45
|
}
|
|
46
46
|
let _client = null;
|
|
47
47
|
function getClient() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../lib/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,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AAO;IACpB,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,MAAM,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,GAAG,IAAI,CAAC;IACf,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC1B,CAAC"}
|
package/dist/lib/utils.d.ts
CHANGED
package/dist/lib/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
import cliProgress from
|
|
3
|
-
import { getSiteStatus } from
|
|
4
|
-
import { API_URL, APP_URL } from
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import cliProgress from 'cli-progress';
|
|
3
|
+
import { getSiteStatus } from './api-client.js';
|
|
4
|
+
import { API_URL, APP_URL } from './const.js';
|
|
5
5
|
export function sleep(ms) {
|
|
6
6
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
7
|
}
|
|
@@ -28,17 +28,17 @@ export async function waitForSync(siteId, maxWaitSeconds = 180) {
|
|
|
28
28
|
}
|
|
29
29
|
return { success: true, blobs: [] };
|
|
30
30
|
}
|
|
31
|
-
const pending = blobs.filter((b) => b.syncStatus ===
|
|
32
|
-
const errors = blobs.filter((b) => b.syncStatus ===
|
|
33
|
-
const success = blobs.filter((b) => b.syncStatus ===
|
|
31
|
+
const pending = blobs.filter((b) => b.syncStatus === 'UPLOADING' || b.syncStatus === 'PROCESSING');
|
|
32
|
+
const errors = blobs.filter((b) => b.syncStatus === 'ERROR');
|
|
33
|
+
const success = blobs.filter((b) => b.syncStatus === 'SUCCESS');
|
|
34
34
|
if (!progressBar && blobs.length > 0) {
|
|
35
35
|
totalFiles = blobs.length;
|
|
36
36
|
progressBar = new cliProgress.SingleBar({
|
|
37
|
-
format:
|
|
38
|
-
chalk.cyan(
|
|
39
|
-
|
|
40
|
-
barCompleteChar:
|
|
41
|
-
barIncompleteChar:
|
|
37
|
+
format: 'Processing |' +
|
|
38
|
+
chalk.cyan('{bar}') +
|
|
39
|
+
'| {percentage}% | {value}/{total} files',
|
|
40
|
+
barCompleteChar: '\u2588',
|
|
41
|
+
barIncompleteChar: '\u2591',
|
|
42
42
|
hideCursor: true,
|
|
43
43
|
}, cliProgress.Presets.shades_classic);
|
|
44
44
|
progressBar.start(totalFiles, success.length);
|
|
@@ -53,7 +53,7 @@ export async function waitForSync(siteId, maxWaitSeconds = 180) {
|
|
|
53
53
|
if (errors.length > 0) {
|
|
54
54
|
console.log(chalk.yellow(`\n⚠️ ${errors.length} file(s) had errors:`));
|
|
55
55
|
for (const blob of errors) {
|
|
56
|
-
console.log(chalk.yellow(` - ${blob.path}: ${blob.syncError ||
|
|
56
|
+
console.log(chalk.yellow(` - ${blob.path}: ${blob.syncError || 'Unknown error'}`));
|
|
57
57
|
}
|
|
58
58
|
return { success: false, blobs, errors };
|
|
59
59
|
}
|
|
@@ -67,7 +67,7 @@ export async function waitForSync(siteId, maxWaitSeconds = 180) {
|
|
|
67
67
|
}
|
|
68
68
|
const statusData = await getSiteStatus(siteId);
|
|
69
69
|
const blobs = statusData.blobs || [];
|
|
70
|
-
const pending = blobs.filter((b) => b.syncStatus ===
|
|
70
|
+
const pending = blobs.filter((b) => b.syncStatus === 'UPLOADING' || b.syncStatus === 'PROCESSING');
|
|
71
71
|
console.log(chalk.yellow(`\n⚠️ Timeout: ${pending.length} file(s) still processing`));
|
|
72
72
|
for (const blob of pending) {
|
|
73
73
|
console.log(chalk.yellow(` - ${blob.path}`));
|
package/dist/package.json
CHANGED
package/package.json
CHANGED