setupcomfyuimodels 1.0.3 → 1.2.0
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/dist/index.js +105 -48
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/src/downloadAssets.ts +45 -16
- package/src/downloadAssets.ts~ +192 -0
- package/src/getConfig.ts +17 -4
- package/src/getConfig.ts~ +11 -0
- package/src/index.ts +7 -2
- package/src/index.ts~ +14 -0
- package/src/replacements.ts +37 -0
- package/src/replacements.ts~ +0 -0
package/dist/index.js
CHANGED
|
@@ -1189,8 +1189,8 @@ var require_command = __commonJS({
|
|
|
1189
1189
|
"node_modules/commander/lib/command.js"(exports2) {
|
|
1190
1190
|
var EventEmitter = require("node:events").EventEmitter;
|
|
1191
1191
|
var childProcess = require("node:child_process");
|
|
1192
|
-
var
|
|
1193
|
-
var
|
|
1192
|
+
var path3 = require("node:path");
|
|
1193
|
+
var fs3 = require("node:fs");
|
|
1194
1194
|
var process3 = require("node:process");
|
|
1195
1195
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
1196
1196
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -2184,7 +2184,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2184
2184
|
* @param {string} subcommandName
|
|
2185
2185
|
*/
|
|
2186
2186
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
2187
|
-
if (
|
|
2187
|
+
if (fs3.existsSync(executableFile)) return;
|
|
2188
2188
|
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
2189
2189
|
const executableMissing = `'${executableFile}' does not exist
|
|
2190
2190
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -2202,11 +2202,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2202
2202
|
let launchWithNode = false;
|
|
2203
2203
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2204
2204
|
function findFile(baseDir, baseName) {
|
|
2205
|
-
const localBin =
|
|
2206
|
-
if (
|
|
2207
|
-
if (sourceExt.includes(
|
|
2205
|
+
const localBin = path3.resolve(baseDir, baseName);
|
|
2206
|
+
if (fs3.existsSync(localBin)) return localBin;
|
|
2207
|
+
if (sourceExt.includes(path3.extname(baseName))) return void 0;
|
|
2208
2208
|
const foundExt = sourceExt.find(
|
|
2209
|
-
(ext) =>
|
|
2209
|
+
(ext) => fs3.existsSync(`${localBin}${ext}`)
|
|
2210
2210
|
);
|
|
2211
2211
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
2212
2212
|
return void 0;
|
|
@@ -2218,21 +2218,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2218
2218
|
if (this._scriptPath) {
|
|
2219
2219
|
let resolvedScriptPath;
|
|
2220
2220
|
try {
|
|
2221
|
-
resolvedScriptPath =
|
|
2221
|
+
resolvedScriptPath = fs3.realpathSync(this._scriptPath);
|
|
2222
2222
|
} catch {
|
|
2223
2223
|
resolvedScriptPath = this._scriptPath;
|
|
2224
2224
|
}
|
|
2225
|
-
executableDir =
|
|
2226
|
-
|
|
2225
|
+
executableDir = path3.resolve(
|
|
2226
|
+
path3.dirname(resolvedScriptPath),
|
|
2227
2227
|
executableDir
|
|
2228
2228
|
);
|
|
2229
2229
|
}
|
|
2230
2230
|
if (executableDir) {
|
|
2231
2231
|
let localFile = findFile(executableDir, executableFile);
|
|
2232
2232
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2233
|
-
const legacyName =
|
|
2233
|
+
const legacyName = path3.basename(
|
|
2234
2234
|
this._scriptPath,
|
|
2235
|
-
|
|
2235
|
+
path3.extname(this._scriptPath)
|
|
2236
2236
|
);
|
|
2237
2237
|
if (legacyName !== this._name) {
|
|
2238
2238
|
localFile = findFile(
|
|
@@ -2243,7 +2243,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2243
2243
|
}
|
|
2244
2244
|
executableFile = localFile || executableFile;
|
|
2245
2245
|
}
|
|
2246
|
-
launchWithNode = sourceExt.includes(
|
|
2246
|
+
launchWithNode = sourceExt.includes(path3.extname(executableFile));
|
|
2247
2247
|
let proc;
|
|
2248
2248
|
if (process3.platform !== "win32") {
|
|
2249
2249
|
if (launchWithNode) {
|
|
@@ -3158,7 +3158,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3158
3158
|
* @return {Command}
|
|
3159
3159
|
*/
|
|
3160
3160
|
nameFromFilename(filename) {
|
|
3161
|
-
this._name =
|
|
3161
|
+
this._name = path3.basename(filename, path3.extname(filename));
|
|
3162
3162
|
return this;
|
|
3163
3163
|
}
|
|
3164
3164
|
/**
|
|
@@ -3172,9 +3172,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3172
3172
|
* @param {string} [path]
|
|
3173
3173
|
* @return {(string|null|Command)}
|
|
3174
3174
|
*/
|
|
3175
|
-
executableDir(
|
|
3176
|
-
if (
|
|
3177
|
-
this._executableDir =
|
|
3175
|
+
executableDir(path4) {
|
|
3176
|
+
if (path4 === void 0) return this._executableDir;
|
|
3177
|
+
this._executableDir = path4;
|
|
3178
3178
|
return this;
|
|
3179
3179
|
}
|
|
3180
3180
|
/**
|
|
@@ -12079,10 +12079,10 @@ var require_stringify = __commonJS({
|
|
|
12079
12079
|
replacer = null;
|
|
12080
12080
|
indent = EMPTY;
|
|
12081
12081
|
};
|
|
12082
|
-
var
|
|
12082
|
+
var join2 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + LF + gap : two ? two.trimRight() + LF + gap : EMPTY;
|
|
12083
12083
|
var join_content = (inside, value, gap) => {
|
|
12084
12084
|
const comment = process_comments(value, PREFIX_BEFORE, gap + indent, true);
|
|
12085
|
-
return
|
|
12085
|
+
return join2(comment, inside, gap);
|
|
12086
12086
|
};
|
|
12087
12087
|
var array_stringify = (value, gap) => {
|
|
12088
12088
|
const deeper_gap = gap + indent;
|
|
@@ -12093,7 +12093,7 @@ var require_stringify = __commonJS({
|
|
|
12093
12093
|
if (i !== 0) {
|
|
12094
12094
|
inside += COMMA;
|
|
12095
12095
|
}
|
|
12096
|
-
const before =
|
|
12096
|
+
const before = join2(
|
|
12097
12097
|
after_comma,
|
|
12098
12098
|
process_comments(value, BEFORE(i), deeper_gap),
|
|
12099
12099
|
deeper_gap
|
|
@@ -12103,7 +12103,7 @@ var require_stringify = __commonJS({
|
|
|
12103
12103
|
inside += process_comments(value, AFTER_VALUE(i), deeper_gap);
|
|
12104
12104
|
after_comma = process_comments(value, AFTER(i), deeper_gap);
|
|
12105
12105
|
}
|
|
12106
|
-
inside +=
|
|
12106
|
+
inside += join2(
|
|
12107
12107
|
after_comma,
|
|
12108
12108
|
process_comments(value, PREFIX_AFTER, deeper_gap),
|
|
12109
12109
|
deeper_gap
|
|
@@ -12128,7 +12128,7 @@ var require_stringify = __commonJS({
|
|
|
12128
12128
|
inside += COMMA;
|
|
12129
12129
|
}
|
|
12130
12130
|
first = false;
|
|
12131
|
-
const before =
|
|
12131
|
+
const before = join2(
|
|
12132
12132
|
after_comma,
|
|
12133
12133
|
process_comments(value, BEFORE(key), deeper_gap),
|
|
12134
12134
|
deeper_gap
|
|
@@ -12138,7 +12138,7 @@ var require_stringify = __commonJS({
|
|
|
12138
12138
|
after_comma = process_comments(value, AFTER(key), deeper_gap);
|
|
12139
12139
|
};
|
|
12140
12140
|
keys.forEach(iteratee);
|
|
12141
|
-
inside +=
|
|
12141
|
+
inside += join2(
|
|
12142
12142
|
after_comma,
|
|
12143
12143
|
process_comments(value, PREFIX_AFTER, deeper_gap),
|
|
12144
12144
|
deeper_gap
|
|
@@ -12494,14 +12494,6 @@ var stopProgressBar = () => {
|
|
|
12494
12494
|
multibar.stop();
|
|
12495
12495
|
};
|
|
12496
12496
|
|
|
12497
|
-
// src/getConfig.ts
|
|
12498
|
-
var import_fs = require("fs");
|
|
12499
|
-
var import_comment_json = __toESM(require_src2());
|
|
12500
|
-
var getConfig = async (configLocation) => {
|
|
12501
|
-
const fileContent = (0, import_fs.readFileSync)(configLocation, "utf-8");
|
|
12502
|
-
return (0, import_comment_json.parse)(fileContent);
|
|
12503
|
-
};
|
|
12504
|
-
|
|
12505
12497
|
// node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
12506
12498
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
12507
12499
|
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
@@ -12998,21 +12990,29 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
|
12998
12990
|
var source_default = chalk;
|
|
12999
12991
|
|
|
13000
12992
|
// src/downloadAssets.ts
|
|
13001
|
-
var {
|
|
13002
|
-
if (!WORKSPACE) {
|
|
13003
|
-
throw new Error("WORKSPACE environment variable is not set.");
|
|
13004
|
-
}
|
|
12993
|
+
var { CIVITAI_TOKEN, HF_TOKEN } = process.env;
|
|
13005
12994
|
var MAX_CONCURRENT_DOWNLOADS = 8;
|
|
13006
12995
|
var concurrentDownloads = 0;
|
|
13007
|
-
var downloadAssets = async (
|
|
13008
|
-
const
|
|
12996
|
+
var downloadAssets = async (config, targetFolder) => {
|
|
12997
|
+
const filesConfigs = [
|
|
12998
|
+
config.files,
|
|
12999
|
+
...Object.entries(config.groups).filter(([groupName]) => config.groupsEnabled[groupName]).map(([_, f]) => f.files)
|
|
13000
|
+
];
|
|
13001
|
+
const foldersConfigs = [
|
|
13002
|
+
config.folders,
|
|
13003
|
+
...Object.entries(config.groups).filter(([groupName]) => config.groupsEnabled[groupName]).map(([_, f]) => f.folders)
|
|
13004
|
+
];
|
|
13009
13005
|
const filePromises = [
|
|
13010
|
-
...
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13006
|
+
...filesConfigs.flatMap(
|
|
13007
|
+
(config2) => Object.entries(config2.files).map(([targetLocation, url]) => {
|
|
13008
|
+
const fileName = import_path.default.basename(targetLocation), dir = import_path.default.dirname(targetLocation);
|
|
13009
|
+
return scheduleDownload(targetFolder, dir, fileName, url);
|
|
13010
|
+
})
|
|
13011
|
+
),
|
|
13012
|
+
...foldersConfigs.flatMap(
|
|
13013
|
+
(config2) => Object.entries(config2).flatMap(
|
|
13014
|
+
([folder, urls]) => urls.map((url) => scheduleDownload(targetFolder, folder, null, url))
|
|
13015
|
+
)
|
|
13016
13016
|
)
|
|
13017
13017
|
];
|
|
13018
13018
|
setTotalProgress(0, filePromises.length);
|
|
@@ -13035,7 +13035,18 @@ var downloadAssets = async (configLocation) => {
|
|
|
13035
13035
|
};
|
|
13036
13036
|
var scheduledDownloads = [];
|
|
13037
13037
|
var results = [];
|
|
13038
|
-
var scheduleDownload = async (targetLocation, targetFileName, url) => {
|
|
13038
|
+
var scheduleDownload = async (globalTargetLocation, targetLocation, targetFileName, url) => {
|
|
13039
|
+
const matchingJob = scheduledDownloads.find(
|
|
13040
|
+
(d) => d.targetLocation === targetLocation && d.targetFileName === targetFileName
|
|
13041
|
+
);
|
|
13042
|
+
if (matchingJob) {
|
|
13043
|
+
if (matchingJob.url !== url) {
|
|
13044
|
+
throw new Error(
|
|
13045
|
+
`Conflicting download jobs for ${targetLocation}/${targetFileName || ""}: ${matchingJob.url} and ${url}`
|
|
13046
|
+
);
|
|
13047
|
+
}
|
|
13048
|
+
return;
|
|
13049
|
+
}
|
|
13039
13050
|
scheduledDownloads.push({ targetLocation, url, targetFileName });
|
|
13040
13051
|
if (concurrentDownloads < MAX_CONCURRENT_DOWNLOADS) {
|
|
13041
13052
|
while (scheduledDownloads.length > 0) {
|
|
@@ -13044,6 +13055,7 @@ var scheduleDownload = async (targetLocation, targetFileName, url) => {
|
|
|
13044
13055
|
concurrentDownloads++;
|
|
13045
13056
|
try {
|
|
13046
13057
|
const skipped = await downloadFile(
|
|
13058
|
+
globalTargetLocation,
|
|
13047
13059
|
nextDownload.targetLocation,
|
|
13048
13060
|
nextDownload.targetFileName,
|
|
13049
13061
|
nextDownload.url
|
|
@@ -13065,10 +13077,12 @@ var scheduleDownload = async (targetLocation, targetFileName, url) => {
|
|
|
13065
13077
|
}
|
|
13066
13078
|
}
|
|
13067
13079
|
};
|
|
13068
|
-
var downloadFile = async (targetLocation, targetFileName, url) => {
|
|
13080
|
+
var downloadFile = async (globalTargetLocation, targetLocation, targetFileName, url) => {
|
|
13069
13081
|
const getTargetId = () => import_path.default.join(targetLocation, targetFileName || "");
|
|
13070
13082
|
try {
|
|
13071
|
-
const targetDir = import_path.default.normalize(
|
|
13083
|
+
const targetDir = import_path.default.normalize(
|
|
13084
|
+
`${globalTargetLocation}/${targetLocation}`
|
|
13085
|
+
);
|
|
13072
13086
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
13073
13087
|
if (targetFileName && fs.existsSync(import_path.default.join(targetDir, targetFileName))) {
|
|
13074
13088
|
log2(`File already exists, skipping: ${getTargetId()}`);
|
|
@@ -13133,11 +13147,54 @@ var downloadFile = async (targetLocation, targetFileName, url) => {
|
|
|
13133
13147
|
}
|
|
13134
13148
|
};
|
|
13135
13149
|
|
|
13150
|
+
// src/replacements.ts
|
|
13151
|
+
var fs2 = __toESM(require("fs"));
|
|
13152
|
+
var path2 = __toESM(require("path"));
|
|
13153
|
+
var replaceInFiles = (config, targetFolder) => {
|
|
13154
|
+
const replacements = config.replacements || [];
|
|
13155
|
+
for (const replacement of replacements) {
|
|
13156
|
+
const filePath = path2.join(targetFolder, replacement.file);
|
|
13157
|
+
if (fs2.existsSync(filePath)) {
|
|
13158
|
+
let fileContent = fs2.readFileSync(filePath, "utf-8");
|
|
13159
|
+
if (fileContent.includes(replacement.original)) {
|
|
13160
|
+
const lines = fileContent.split("\n");
|
|
13161
|
+
if (lines.length >= replacement.line && lines[replacement.line - 1].includes(replacement.original)) {
|
|
13162
|
+
lines[replacement.line - 1] = lines[replacement.line - 1].replace(
|
|
13163
|
+
replacement.original,
|
|
13164
|
+
replacement.replacement
|
|
13165
|
+
);
|
|
13166
|
+
fileContent = lines.join("\n");
|
|
13167
|
+
} else {
|
|
13168
|
+
console.warn(
|
|
13169
|
+
`Line number mismatch in ${replacement.file}. Expected line ${replacement.line} to contain the original code.`
|
|
13170
|
+
);
|
|
13171
|
+
}
|
|
13172
|
+
fs2.writeFileSync(filePath, fileContent, "utf-8");
|
|
13173
|
+
console.log(`Patched ${replacement.file} at line ${replacement.line}`);
|
|
13174
|
+
} else {
|
|
13175
|
+
console.warn(`Original code not found in ${replacement.file}`);
|
|
13176
|
+
}
|
|
13177
|
+
} else {
|
|
13178
|
+
console.warn(`File not found: ${replacement.file}`);
|
|
13179
|
+
}
|
|
13180
|
+
}
|
|
13181
|
+
};
|
|
13182
|
+
|
|
13183
|
+
// src/getConfig.ts
|
|
13184
|
+
var import_fs = require("fs");
|
|
13185
|
+
var import_comment_json = __toESM(require_src2());
|
|
13186
|
+
var getConfig = async (configLocation) => {
|
|
13187
|
+
const fileContent = (0, import_fs.readFileSync)(configLocation, "utf-8");
|
|
13188
|
+
return (0, import_comment_json.parse)(fileContent);
|
|
13189
|
+
};
|
|
13190
|
+
|
|
13136
13191
|
// src/index.ts
|
|
13137
13192
|
var program2 = new Command();
|
|
13138
13193
|
program2.name("Setup ComfyUi Models");
|
|
13139
|
-
program2.command("download").argument("<config>", "JSON config file location").action(async (configLocation) => {
|
|
13140
|
-
await
|
|
13194
|
+
program2.command("download").argument("<config>", "JSON config file location").option("-l, --location <path>", "Target download location").action(async (configLocation, options) => {
|
|
13195
|
+
const config = await getConfig(configLocation);
|
|
13196
|
+
await downloadAssets(config, options.location || "./");
|
|
13197
|
+
replaceInFiles(config, options.location || "./");
|
|
13141
13198
|
});
|
|
13142
13199
|
program2.parse();
|
|
13143
13200
|
//# sourceMappingURL=index.js.map
|