@uxf/scripts 11.60.0 → 11.61.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/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/scripts",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.61.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"uxf-audit": "bin/uxf-audit.js",
|
|
8
|
+
"uxf-claude-sync": "bin/uxf-claude-sync.js",
|
|
8
9
|
"uxf-lunch": "bin/uxf-lunch.js",
|
|
9
10
|
"uxf-push-notifier": "bin/uxf-push-notifier.js",
|
|
10
11
|
"uxf-release": "bin/uxf-release.js",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const { argv } = require("process");
|
|
2
|
+
|
|
3
|
+
module.exports = async () => {
|
|
4
|
+
const cli = require("yargs")
|
|
5
|
+
.command("$0", "UXF Claude code sync", (yargs) => {
|
|
6
|
+
yargs.demandCommand(0, 0).usage(`UXF Claude code sync
|
|
7
|
+
Usage:
|
|
8
|
+
uxf-claude-sync [options]
|
|
9
|
+
|
|
10
|
+
`);
|
|
11
|
+
})
|
|
12
|
+
.option("url", {
|
|
13
|
+
describe: "Global guidelines URL",
|
|
14
|
+
type: "string",
|
|
15
|
+
group: "Options",
|
|
16
|
+
})
|
|
17
|
+
.option("h", { alias: "help", group: "Options" })
|
|
18
|
+
.strict(false)
|
|
19
|
+
.exitProcess(false);
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const { help, url, ...options } = cli.parse(argv.slice(2));
|
|
23
|
+
|
|
24
|
+
if (Boolean(help)) {
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await require("./index")(
|
|
29
|
+
url,
|
|
30
|
+
);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.error(e);
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const https = require('https');
|
|
3
|
+
const http = require('http');
|
|
4
|
+
|
|
5
|
+
const fileName = 'CLAUDE.md';
|
|
6
|
+
const header = '# Global guidelines';
|
|
7
|
+
|
|
8
|
+
// Funkce pro stažení obsahu z URL
|
|
9
|
+
function downloadContent(url) {
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
const protocol = url.startsWith('https') ? https : http;
|
|
12
|
+
|
|
13
|
+
protocol.get(url, (response) => {
|
|
14
|
+
if (response.statusCode !== 200) {
|
|
15
|
+
reject(new Error(`Chyba při stahování: HTTP status ${response.statusCode}`));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let data = '';
|
|
20
|
+
response.on('data', (chunk) => {
|
|
21
|
+
data += chunk;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
response.on('end', () => {
|
|
25
|
+
resolve(data);
|
|
26
|
+
});
|
|
27
|
+
}).on('error', (error) => {
|
|
28
|
+
reject(error);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Funkce pro úpravu souboru
|
|
34
|
+
function processFile(content) {
|
|
35
|
+
try {
|
|
36
|
+
// Kontrola, zda soubor existuje
|
|
37
|
+
let fileContent = '';
|
|
38
|
+
try {
|
|
39
|
+
fileContent = fs.readFileSync(fileName, 'utf8');
|
|
40
|
+
} catch (error) {
|
|
41
|
+
// Soubor neexistuje, vytvoříme nový
|
|
42
|
+
console.log(`Soubor ${fileName} neexistuje, vytvářím nový...`);
|
|
43
|
+
fs.writeFileSync(fileName, `${header}\n\n${content}\n`);
|
|
44
|
+
console.log(`Hotovo! Obsah byl uložen do nově vytvořeného souboru ${fileName}.`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Kontrola, zda soubor obsahuje nadpis
|
|
49
|
+
if (fileContent.includes(header)) {
|
|
50
|
+
console.log(`Nadpis '${header}' nalezen v souboru, nahrazuji obsah pod ním...`);
|
|
51
|
+
|
|
52
|
+
const parts = fileContent.split(header);
|
|
53
|
+
let newContent = parts[0] + header + '\n\n' + content;
|
|
54
|
+
|
|
55
|
+
fs.writeFileSync(fileName, newContent);
|
|
56
|
+
console.log(`Hotovo! Obsah pod nadpisem '${header}' byl nahrazen.`);
|
|
57
|
+
} else {
|
|
58
|
+
console.log(`Nadpis '${header}' nenalezen v souboru, přidávám na konec...`);
|
|
59
|
+
fs.writeFileSync(fileName, `${fileContent.trim()}\n\n${header}\n\n${content}\n`);
|
|
60
|
+
console.log(`Hotovo! Nadpis '${header}' a obsah byly přidány na konec souboru ${fileName}.`);
|
|
61
|
+
}
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(`Chyba při zpracování souboru: ${error.message}`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = async function(url) {
|
|
69
|
+
console.log(`Stahuji obsah z ${url}...`);
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
const content = await downloadContent(url);
|
|
73
|
+
processFile(content);
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error(`Chyba: ${error.message}`);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|