freestyle-sync 0.1.11 → 0.1.12
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/src/main.js +39 -2
- package/package.json +1 -1
package/dist/src/main.js
CHANGED
|
@@ -30,6 +30,8 @@ const DEFAULT_STACK_API_URL = "https://api.stack-auth.com";
|
|
|
30
30
|
const DEFAULT_STACK_PROJECT_ID = "0edf478c-f123-46fb-818f-34c0024a9f35";
|
|
31
31
|
const DEFAULT_STACK_PUBLISHABLE_CLIENT_KEY = "pck_h2aft7g9pqjzrkdnzs199h1may5wjtdtdxeex7m2wzp1r";
|
|
32
32
|
const STACK_REFRESH_TOKEN_ENV_KEY = "FREESTYLE_STACK_REFRESH_TOKEN";
|
|
33
|
+
const GENERATED_UPLOAD_DIRECTORY_NAMES = new Set([".cache", ".freestyle-sync", ".git", ".next", ".turbo", ".vercel", ".vite", "build", "coverage", "dist", "node_modules", "target"]);
|
|
34
|
+
const DEFAULT_PROJECT_EXCLUDES = [".freestyle-sync"];
|
|
33
35
|
const USE_UNICODE_OUTPUT = process.stdout.isTTY && (process.env.TERM !== "dumb" || Boolean(process.env.TERM_PROGRAM));
|
|
34
36
|
const USE_STYLED_OUTPUT = process.stdout.isTTY && process.env.NO_COLOR !== "1";
|
|
35
37
|
const DEFAULT_CONFIG_DEPENDENCIES = [
|
|
@@ -110,7 +112,6 @@ async function main() {
|
|
|
110
112
|
}
|
|
111
113
|
export async function sync(sdkOptions) {
|
|
112
114
|
const options = await resolveCliOptions(sdkOptions.options);
|
|
113
|
-
printHeading(CLI_NAME);
|
|
114
115
|
config = sdkOptions.config;
|
|
115
116
|
plugins = config.plugins;
|
|
116
117
|
const pluginPreferences = await updatePluginPreferences(options, sdkOptions.pluginPreferences);
|
|
@@ -745,7 +746,7 @@ async function resolveProjectSyncConfig(options) {
|
|
|
745
746
|
configs.push(pluginConfig);
|
|
746
747
|
}
|
|
747
748
|
return {
|
|
748
|
-
exclude: configs.flatMap((projectConfig) => projectConfig.exclude ?? []).map(normalizeProjectPattern),
|
|
749
|
+
exclude: [...DEFAULT_PROJECT_EXCLUDES, ...configs.flatMap((projectConfig) => projectConfig.exclude ?? [])].map(normalizeProjectPattern),
|
|
749
750
|
include: configs.flatMap((projectConfig) => normalizeProjectIncludes(options.projectRoot, projectConfig.include ?? [])),
|
|
750
751
|
};
|
|
751
752
|
}
|
|
@@ -1081,6 +1082,8 @@ function printPlan(options, projectChanges, contextChanges, envExports, cache) {
|
|
|
1081
1082
|
console.log(`${dim(" Project files:")} ${projectChanges.changed.length} changed, ${projectChanges.removed.length} removed, ${projectChanges.unchanged} unchanged`);
|
|
1082
1083
|
console.log(`${dim(" Context files:")} ${contextChanges.changed.length} changed, ${contextChanges.removed.length} removed, ${contextChanges.unchanged} unchanged`);
|
|
1083
1084
|
console.log(`${dim(" Estimated upload:")} ${formatBytes(totalEntrySize(projectChanges.changed))} project, ${formatBytes(totalEntrySize(contextChanges.changed))} context`);
|
|
1085
|
+
printUploadBreakdown("Project upload contributors", projectUploadContributors(projectChanges.changed), "consider sync.exclude for generated folders");
|
|
1086
|
+
printUploadBreakdown("Context upload contributors", contextUploadContributors(contextChanges.changed), "disable unneeded context plugins to skip");
|
|
1084
1087
|
if (Object.keys(envExports).length > 0) {
|
|
1085
1088
|
console.log(`${dim(" Environment exports:")} ${Object.keys(envExports).length}`);
|
|
1086
1089
|
}
|
|
@@ -1089,6 +1092,40 @@ function printPlan(options, projectChanges, contextChanges, envExports, cache) {
|
|
|
1089
1092
|
function totalEntrySize(entries) {
|
|
1090
1093
|
return entries.reduce((total, entry) => total + entry.size, 0);
|
|
1091
1094
|
}
|
|
1095
|
+
function projectUploadContributors(entries) {
|
|
1096
|
+
return largestContributors(entries, (entry) => contributionPath(entry.relativePath));
|
|
1097
|
+
}
|
|
1098
|
+
function contextUploadContributors(entries) {
|
|
1099
|
+
return largestContributors(entries, (entry) => entry.label);
|
|
1100
|
+
}
|
|
1101
|
+
function contributionPath(relativePath) {
|
|
1102
|
+
const parts = relativePath.split("/").filter(Boolean);
|
|
1103
|
+
if (parts.length <= 1)
|
|
1104
|
+
return relativePath;
|
|
1105
|
+
const generatedDirectoryIndex = parts.findIndex((part) => GENERATED_UPLOAD_DIRECTORY_NAMES.has(part));
|
|
1106
|
+
if (generatedDirectoryIndex >= 0)
|
|
1107
|
+
return parts.slice(0, generatedDirectoryIndex + 1).join("/");
|
|
1108
|
+
return parts.slice(0, Math.min(parts.length - 1, 3)).join("/");
|
|
1109
|
+
}
|
|
1110
|
+
function largestContributors(entries, bucketForEntry) {
|
|
1111
|
+
const buckets = new Map();
|
|
1112
|
+
for (const entry of entries) {
|
|
1113
|
+
const bucketName = bucketForEntry(entry);
|
|
1114
|
+
const bucket = buckets.get(bucketName) ?? { path: bucketName, size: 0, files: 0 };
|
|
1115
|
+
bucket.size += entry.size;
|
|
1116
|
+
bucket.files += 1;
|
|
1117
|
+
buckets.set(bucketName, bucket);
|
|
1118
|
+
}
|
|
1119
|
+
return Array.from(buckets.values()).sort((left, right) => right.size - left.size).slice(0, 6);
|
|
1120
|
+
}
|
|
1121
|
+
function printUploadBreakdown(title, contributors, hint) {
|
|
1122
|
+
if (contributors.length === 0)
|
|
1123
|
+
return;
|
|
1124
|
+
console.log(`${dim(` ${title}:`)} ${hint}`);
|
|
1125
|
+
for (const contributor of contributors) {
|
|
1126
|
+
console.log(`${dim(" -")} ${formatBytes(contributor.size).padStart(9)} ${contributor.path} ${dim(`(${contributor.files} ${contributor.files === 1 ? "file" : "files"})`)}`);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1092
1129
|
function printHeading(name) {
|
|
1093
1130
|
console.log(`${bold(name)} ${dim(`${symbol("→", "-")} Freestyle sync`)}`);
|
|
1094
1131
|
console.log("");
|