@atlashub/smartstack-cli 2.7.4 → 2.8.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 +97 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37233,7 +37233,7 @@ var require_lodash5 = __commonJS({
|
|
|
37233
37233
|
function isObjectLike(value) {
|
|
37234
37234
|
return !!value && typeof value == "object";
|
|
37235
37235
|
}
|
|
37236
|
-
function
|
|
37236
|
+
function isPlainObject2(value) {
|
|
37237
37237
|
if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) {
|
|
37238
37238
|
return false;
|
|
37239
37239
|
}
|
|
@@ -37244,7 +37244,7 @@ var require_lodash5 = __commonJS({
|
|
|
37244
37244
|
var Ctor = hasOwnProperty.call(proto2, "constructor") && proto2.constructor;
|
|
37245
37245
|
return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
|
|
37246
37246
|
}
|
|
37247
|
-
module2.exports =
|
|
37247
|
+
module2.exports = isPlainObject2;
|
|
37248
37248
|
}
|
|
37249
37249
|
});
|
|
37250
37250
|
|
|
@@ -37360,7 +37360,7 @@ var require_sign = __commonJS({
|
|
|
37360
37360
|
var isBoolean = require_lodash2();
|
|
37361
37361
|
var isInteger = require_lodash3();
|
|
37362
37362
|
var isNumber = require_lodash4();
|
|
37363
|
-
var
|
|
37363
|
+
var isPlainObject2 = require_lodash5();
|
|
37364
37364
|
var isString = require_lodash6();
|
|
37365
37365
|
var once = require_lodash7();
|
|
37366
37366
|
var { KeyObject, createSecretKey, createPrivateKey } = require("crypto");
|
|
@@ -37379,7 +37379,7 @@ var require_sign = __commonJS({
|
|
|
37379
37379
|
return isString(value) || Array.isArray(value);
|
|
37380
37380
|
}, message: '"audience" must be a string or array' },
|
|
37381
37381
|
algorithm: { isValid: includes.bind(null, SUPPORTED_ALGS), message: '"algorithm" must be a valid string enum value' },
|
|
37382
|
-
header: { isValid:
|
|
37382
|
+
header: { isValid: isPlainObject2, message: '"header" must be an object' },
|
|
37383
37383
|
encoding: { isValid: isString, message: '"encoding" must be a string' },
|
|
37384
37384
|
issuer: { isValid: isString, message: '"issuer" must be a string' },
|
|
37385
37385
|
subject: { isValid: isString, message: '"subject" must be a string' },
|
|
@@ -37396,7 +37396,7 @@ var require_sign = __commonJS({
|
|
|
37396
37396
|
nbf: { isValid: isNumber, message: '"nbf" should be a number of seconds' }
|
|
37397
37397
|
};
|
|
37398
37398
|
function validate3(schema, allowUnknown, object, parameterName) {
|
|
37399
|
-
if (!
|
|
37399
|
+
if (!isPlainObject2(object)) {
|
|
37400
37400
|
throw new Error('Expected "' + parameterName + '" to be a plain object.');
|
|
37401
37401
|
}
|
|
37402
37402
|
Object.keys(object).forEach(function(key) {
|
|
@@ -44464,16 +44464,16 @@ var require_chainedTokenCredential = __commonJS({
|
|
|
44464
44464
|
// node_modules/uuid/dist/esm-node/rng.js
|
|
44465
44465
|
function rng() {
|
|
44466
44466
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
44467
|
-
|
|
44467
|
+
import_crypto4.default.randomFillSync(rnds8Pool);
|
|
44468
44468
|
poolPtr = 0;
|
|
44469
44469
|
}
|
|
44470
44470
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
44471
44471
|
}
|
|
44472
|
-
var
|
|
44472
|
+
var import_crypto4, rnds8Pool, poolPtr;
|
|
44473
44473
|
var init_rng = __esm({
|
|
44474
44474
|
"node_modules/uuid/dist/esm-node/rng.js"() {
|
|
44475
44475
|
"use strict";
|
|
44476
|
-
|
|
44476
|
+
import_crypto4 = __toESM(require("crypto"));
|
|
44477
44477
|
rnds8Pool = new Uint8Array(256);
|
|
44478
44478
|
poolPtr = rnds8Pool.length;
|
|
44479
44479
|
}
|
|
@@ -44678,13 +44678,13 @@ function md5(bytes) {
|
|
|
44678
44678
|
} else if (typeof bytes === "string") {
|
|
44679
44679
|
bytes = Buffer.from(bytes, "utf8");
|
|
44680
44680
|
}
|
|
44681
|
-
return
|
|
44681
|
+
return import_crypto5.default.createHash("md5").update(bytes).digest();
|
|
44682
44682
|
}
|
|
44683
|
-
var
|
|
44683
|
+
var import_crypto5, md5_default;
|
|
44684
44684
|
var init_md5 = __esm({
|
|
44685
44685
|
"node_modules/uuid/dist/esm-node/md5.js"() {
|
|
44686
44686
|
"use strict";
|
|
44687
|
-
|
|
44687
|
+
import_crypto5 = __toESM(require("crypto"));
|
|
44688
44688
|
md5_default = md5;
|
|
44689
44689
|
}
|
|
44690
44690
|
});
|
|
@@ -44733,13 +44733,13 @@ function sha1(bytes) {
|
|
|
44733
44733
|
} else if (typeof bytes === "string") {
|
|
44734
44734
|
bytes = Buffer.from(bytes, "utf8");
|
|
44735
44735
|
}
|
|
44736
|
-
return
|
|
44736
|
+
return import_crypto6.default.createHash("sha1").update(bytes).digest();
|
|
44737
44737
|
}
|
|
44738
|
-
var
|
|
44738
|
+
var import_crypto6, sha1_default;
|
|
44739
44739
|
var init_sha1 = __esm({
|
|
44740
44740
|
"node_modules/uuid/dist/esm-node/sha1.js"() {
|
|
44741
44741
|
"use strict";
|
|
44742
|
-
|
|
44742
|
+
import_crypto6 = __toESM(require("crypto"));
|
|
44743
44743
|
sha1_default = sha1;
|
|
44744
44744
|
}
|
|
44745
44745
|
});
|
|
@@ -116582,6 +116582,13 @@ EndGlobal
|
|
|
116582
116582
|
}
|
|
116583
116583
|
}
|
|
116584
116584
|
}
|
|
116585
|
+
for (const placeholder of ["appsettings.json", "appsettings.Development.json"]) {
|
|
116586
|
+
const placeholderPath = (0, import_path6.join)(apiDir, placeholder);
|
|
116587
|
+
if (await import_fs_extra5.default.pathExists(placeholderPath)) {
|
|
116588
|
+
await import_fs_extra5.default.remove(placeholderPath);
|
|
116589
|
+
logger.info(`Removed placeholder: ${projectName}.Api/${placeholder}`);
|
|
116590
|
+
}
|
|
116591
|
+
}
|
|
116585
116592
|
}
|
|
116586
116593
|
if (!dryRun) {
|
|
116587
116594
|
for (const { proj } of projects) {
|
|
@@ -124527,7 +124534,36 @@ var glob = Object.assign(glob_, {
|
|
|
124527
124534
|
});
|
|
124528
124535
|
glob.glob = glob;
|
|
124529
124536
|
|
|
124537
|
+
// src/lib/config-sync.ts
|
|
124538
|
+
var import_crypto3 = require("crypto");
|
|
124539
|
+
function addMissingKeys(target, template, prefix = "") {
|
|
124540
|
+
const added = [];
|
|
124541
|
+
for (const key of Object.keys(template)) {
|
|
124542
|
+
const path5 = prefix ? `${prefix}.${key}` : key;
|
|
124543
|
+
if (!(key in target)) {
|
|
124544
|
+
target[key] = template[key];
|
|
124545
|
+
added.push(path5);
|
|
124546
|
+
} else if (isPlainObject(target[key]) && isPlainObject(template[key])) {
|
|
124547
|
+
const nested = addMissingKeys(
|
|
124548
|
+
target[key],
|
|
124549
|
+
template[key],
|
|
124550
|
+
path5
|
|
124551
|
+
);
|
|
124552
|
+
added.push(...nested);
|
|
124553
|
+
}
|
|
124554
|
+
}
|
|
124555
|
+
return added;
|
|
124556
|
+
}
|
|
124557
|
+
function resolveTemplatePlaceholders(content, projectName) {
|
|
124558
|
+
const secret = (0, import_crypto3.randomBytes)(32).toString("hex");
|
|
124559
|
+
return content.replace(/\{\{ProjectName\}\}/g, projectName).replace(/\{\{GenerateRandomSecret\}\}/g, secret).replace(/\{\{ProjectDomain\}\}/g, `${projectName.toLowerCase()}.app`).replace(/\{\{ProjectNameLower\}\}/g, projectName.toLowerCase());
|
|
124560
|
+
}
|
|
124561
|
+
function isPlainObject(value) {
|
|
124562
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
124563
|
+
}
|
|
124564
|
+
|
|
124530
124565
|
// src/commands/upgrade.ts
|
|
124566
|
+
var TEMPLATES_DIR3 = (0, import_path7.join)((0, import_path7.dirname)(__dirname), "templates", "project");
|
|
124531
124567
|
async function getLatestNuGetVersion2(packageName, prerelease) {
|
|
124532
124568
|
try {
|
|
124533
124569
|
const response = await fetch(`https://api.nuget.org/v3-flatcontainer/${packageName.toLowerCase()}/index.json`);
|
|
@@ -124785,6 +124821,31 @@ async function executeMigrations(projectDir, fromVersion, toVersion, dryRun) {
|
|
|
124785
124821
|
hasErrors
|
|
124786
124822
|
};
|
|
124787
124823
|
}
|
|
124824
|
+
async function syncAppSettings(projectDir, baseNamespace, dryRun) {
|
|
124825
|
+
const appSettingsPath = (0, import_path7.join)(projectDir, "src", `${baseNamespace}.Api`, "appsettings.json");
|
|
124826
|
+
if (!await import_fs_extra6.default.pathExists(appSettingsPath)) {
|
|
124827
|
+
logger.warning("appsettings.json not found, skipping config sync");
|
|
124828
|
+
return [];
|
|
124829
|
+
}
|
|
124830
|
+
const templatePath = (0, import_path7.join)(TEMPLATES_DIR3, "appsettings.json.template");
|
|
124831
|
+
if (!await import_fs_extra6.default.pathExists(templatePath)) {
|
|
124832
|
+
logger.warning("appsettings.json.template not found, skipping config sync");
|
|
124833
|
+
return [];
|
|
124834
|
+
}
|
|
124835
|
+
const rawTemplate = await import_fs_extra6.default.readFile(templatePath, "utf-8");
|
|
124836
|
+
const resolvedTemplate = resolveTemplatePlaceholders(rawTemplate, baseNamespace);
|
|
124837
|
+
const templateJson = JSON.parse(resolvedTemplate);
|
|
124838
|
+
const clientContent = await import_fs_extra6.default.readFile(appSettingsPath, "utf-8");
|
|
124839
|
+
const clientJson = JSON.parse(clientContent);
|
|
124840
|
+
const added = addMissingKeys(clientJson, templateJson);
|
|
124841
|
+
if (added.length === 0) {
|
|
124842
|
+
return [];
|
|
124843
|
+
}
|
|
124844
|
+
if (!dryRun) {
|
|
124845
|
+
await import_fs_extra6.default.writeFile(appSettingsPath, JSON.stringify(clientJson, null, 2));
|
|
124846
|
+
}
|
|
124847
|
+
return added;
|
|
124848
|
+
}
|
|
124788
124849
|
var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack packages to the latest version").option("--preview", "Upgrade to latest preview/prerelease version").option("--dry-run", "Show what would be upgraded without actually upgrading").action(async (options) => {
|
|
124789
124850
|
logger.header("SmartStack Package Upgrade");
|
|
124790
124851
|
const dryRun = options.dryRun || false;
|
|
@@ -124796,7 +124857,8 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
|
|
|
124796
124857
|
otherPkgSkipped: 0,
|
|
124797
124858
|
otherPkgFailed: 0,
|
|
124798
124859
|
npmUpgraded: false,
|
|
124799
|
-
npmSkipped: false
|
|
124860
|
+
npmSkipped: false,
|
|
124861
|
+
configSynced: 0
|
|
124800
124862
|
};
|
|
124801
124863
|
if (dryRun) {
|
|
124802
124864
|
logger.warning("DRY RUN MODE - No packages will be upgraded");
|
|
@@ -124971,6 +125033,22 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
|
|
|
124971
125033
|
logger.info("No code migrations needed.");
|
|
124972
125034
|
console.log();
|
|
124973
125035
|
}
|
|
125036
|
+
logger.info("Syncing appsettings.json...");
|
|
125037
|
+
const addedKeys = await syncAppSettings(projectDir, config.baseNamespace, dryRun);
|
|
125038
|
+
result.configSynced = addedKeys.length;
|
|
125039
|
+
if (addedKeys.length > 0) {
|
|
125040
|
+
if (dryRun) {
|
|
125041
|
+
logger.warning(`[DRY RUN] Would add ${addedKeys.length} new setting(s) to appsettings.json`);
|
|
125042
|
+
}
|
|
125043
|
+
for (const key of addedKeys) {
|
|
125044
|
+
logger.info(` ${source_default.green("+")} ${key}`);
|
|
125045
|
+
}
|
|
125046
|
+
logger.success(`${addedKeys.length} new setting(s) added to appsettings.json`);
|
|
125047
|
+
console.log();
|
|
125048
|
+
} else {
|
|
125049
|
+
logger.info(`appsettings.json ${source_default.green("\u2713")} up to date`);
|
|
125050
|
+
console.log();
|
|
125051
|
+
}
|
|
124974
125052
|
if (!dryRun && nugetVersion) {
|
|
124975
125053
|
config.smartStackVersion = nugetVersion;
|
|
124976
125054
|
const configPath = (0, import_path7.join)(projectDir, ".smartstack", "config.json");
|
|
@@ -124978,7 +125056,7 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
|
|
|
124978
125056
|
logger.success(`Updated config version to ${source_default.cyan(nugetVersion)}`);
|
|
124979
125057
|
console.log();
|
|
124980
125058
|
}
|
|
124981
|
-
const totalChanged = result.nugetUpgraded + result.otherPkgUpdated + (result.npmUpgraded ? 1 : 0) + migrationSummary.totalApplied;
|
|
125059
|
+
const totalChanged = result.nugetUpgraded + result.otherPkgUpdated + (result.npmUpgraded ? 1 : 0) + migrationSummary.totalApplied + result.configSynced;
|
|
124982
125060
|
const allUpToDate = totalChanged === 0 && result.nugetFailed === 0 && result.otherPkgFailed === 0;
|
|
124983
125061
|
if (allUpToDate) {
|
|
124984
125062
|
const summary = [
|
|
@@ -125019,6 +125097,9 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
|
|
|
125019
125097
|
if (migrationSummary.totalApplied > 0) {
|
|
125020
125098
|
lines.push(` ${source_default.green("\u2713")} Code migrations: ${migrationSummary.totalApplied} applied`);
|
|
125021
125099
|
}
|
|
125100
|
+
if (result.configSynced > 0) {
|
|
125101
|
+
lines.push(` ${source_default.green("\u2713")} Config: ${result.configSynced} new setting(s) added`);
|
|
125102
|
+
}
|
|
125022
125103
|
lines.push("");
|
|
125023
125104
|
lines.push(source_default.yellow("Next steps:"));
|
|
125024
125105
|
lines.push(` 1. Review changes: ${source_default.cyan("git diff")}`);
|