atmn 1.1.1 → 1.1.2
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/cli.js +53 -19
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -44910,6 +44910,23 @@ function planIdToVarName(id) {
|
|
|
44910
44910
|
function featureIdToVarName(id) {
|
|
44911
44911
|
return idToVarName(id, "feature_");
|
|
44912
44912
|
}
|
|
44913
|
+
function resolveVarNames(featureIds, planIds) {
|
|
44914
|
+
const featureVarMap = new Map;
|
|
44915
|
+
const planVarMap = new Map;
|
|
44916
|
+
for (const id of featureIds) {
|
|
44917
|
+
featureVarMap.set(id, featureIdToVarName(id));
|
|
44918
|
+
}
|
|
44919
|
+
const usedNames = new Set(featureVarMap.values());
|
|
44920
|
+
for (const id of planIds) {
|
|
44921
|
+
let varName = planIdToVarName(id);
|
|
44922
|
+
if (usedNames.has(varName)) {
|
|
44923
|
+
varName = `${varName}_plan`;
|
|
44924
|
+
}
|
|
44925
|
+
planVarMap.set(id, varName);
|
|
44926
|
+
usedNames.add(varName);
|
|
44927
|
+
}
|
|
44928
|
+
return { featureVarMap, planVarMap };
|
|
44929
|
+
}
|
|
44913
44930
|
function escapeString(str) {
|
|
44914
44931
|
return str.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/"/g, "\\\"").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t");
|
|
44915
44932
|
}
|
|
@@ -44940,8 +44957,8 @@ function formatValue(value) {
|
|
|
44940
44957
|
}
|
|
44941
44958
|
|
|
44942
44959
|
// src/lib/transforms/sdkToCode/feature.ts
|
|
44943
|
-
function buildFeatureCode(feature) {
|
|
44944
|
-
const varName = featureIdToVarName(feature.id);
|
|
44960
|
+
function buildFeatureCode(feature, varNameOverride) {
|
|
44961
|
+
const varName = varNameOverride ?? featureIdToVarName(feature.id);
|
|
44945
44962
|
const lines = [];
|
|
44946
44963
|
lines.push(`export const ${varName} = feature({`);
|
|
44947
44964
|
lines.push(` id: '${feature.id}',`);
|
|
@@ -45037,8 +45054,8 @@ function buildPlanItemCode(planItem, _features, featureVarMap) {
|
|
|
45037
45054
|
var init_planItem2 = () => {};
|
|
45038
45055
|
|
|
45039
45056
|
// src/lib/transforms/sdkToCode/plan.ts
|
|
45040
|
-
function buildPlanCode(plan, features, featureVarMap) {
|
|
45041
|
-
const varName = planIdToVarName(plan.id);
|
|
45057
|
+
function buildPlanCode(plan, features, featureVarMap, varNameOverride) {
|
|
45058
|
+
const varName = varNameOverride ?? planIdToVarName(plan.id);
|
|
45042
45059
|
const lines = [];
|
|
45043
45060
|
lines.push(`export const ${varName} = plan({`);
|
|
45044
45061
|
lines.push(` id: '${plan.id}',`);
|
|
@@ -45083,18 +45100,10 @@ var init_plan2 = __esm(() => {
|
|
|
45083
45100
|
// src/lib/transforms/inPlaceUpdate/updateConfig.ts
|
|
45084
45101
|
import { existsSync as existsSync4, writeFileSync as writeFileSync2 } from "node:fs";
|
|
45085
45102
|
function generateFeatureCode(feature, existingVarName) {
|
|
45086
|
-
|
|
45087
|
-
if (existingVarName) {
|
|
45088
|
-
return code.replace(/export const \w+/, `export const ${existingVarName}`);
|
|
45089
|
-
}
|
|
45090
|
-
return code;
|
|
45103
|
+
return buildFeatureCode(feature, existingVarName);
|
|
45091
45104
|
}
|
|
45092
45105
|
function generatePlanCode(plan, features, existingVarName, featureVarMap) {
|
|
45093
|
-
|
|
45094
|
-
if (existingVarName) {
|
|
45095
|
-
return code.replace(/export const \w+/, `export const ${existingVarName}`);
|
|
45096
|
-
}
|
|
45097
|
-
return code;
|
|
45106
|
+
return buildPlanCode(plan, features, featureVarMap, existingVarName);
|
|
45098
45107
|
}
|
|
45099
45108
|
async function updateConfigInPlace(features, plans, cwd2 = process.cwd()) {
|
|
45100
45109
|
const configPath = resolveConfigPath(cwd2);
|
|
@@ -45118,6 +45127,30 @@ async function updateConfigInPlace(features, plans, cwd2 = process.cwd()) {
|
|
|
45118
45127
|
featureVarMap.set(entity.id, entity.varName);
|
|
45119
45128
|
}
|
|
45120
45129
|
}
|
|
45130
|
+
const existingVarNames = new Set(parsed.entities.map((e) => e.varName));
|
|
45131
|
+
const newFeatureIds = features.filter((f) => !featureVarMap.has(f.id)).map((f) => f.id);
|
|
45132
|
+
const newFeatureVarMap = new Map;
|
|
45133
|
+
for (const id of newFeatureIds) {
|
|
45134
|
+
const { featureVarMap: resolved } = resolveVarNames([id], []);
|
|
45135
|
+
let varName = resolved.get(id);
|
|
45136
|
+
if (existingVarNames.has(varName)) {
|
|
45137
|
+
varName = `${varName}_feature`;
|
|
45138
|
+
}
|
|
45139
|
+
newFeatureVarMap.set(id, varName);
|
|
45140
|
+
existingVarNames.add(varName);
|
|
45141
|
+
featureVarMap.set(id, varName);
|
|
45142
|
+
}
|
|
45143
|
+
const existingPlanIds = new Set(parsed.entities.filter((e) => e.type === "plan").map((e) => e.id));
|
|
45144
|
+
const newPlanIds = plans.filter((p) => !existingPlanIds.has(p.id)).map((p) => p.id);
|
|
45145
|
+
const newPlanVarMap = new Map;
|
|
45146
|
+
for (const id of newPlanIds) {
|
|
45147
|
+
let varName = planIdToVarName(id);
|
|
45148
|
+
if (existingVarNames.has(varName)) {
|
|
45149
|
+
varName = `${varName}_plan`;
|
|
45150
|
+
}
|
|
45151
|
+
newPlanVarMap.set(id, varName);
|
|
45152
|
+
existingVarNames.add(varName);
|
|
45153
|
+
}
|
|
45121
45154
|
const matchedFeatureIds = new Set;
|
|
45122
45155
|
const matchedPlanIds = new Set;
|
|
45123
45156
|
const outputBlocks = [];
|
|
@@ -45209,7 +45242,7 @@ async function updateConfigInPlace(features, plans, cwd2 = process.cwd()) {
|
|
|
45209
45242
|
}
|
|
45210
45243
|
const newFeatures = features.filter((f) => !matchedFeatureIds.has(f.id));
|
|
45211
45244
|
if (newFeatures.length > 0) {
|
|
45212
|
-
const newFeatureCode = newFeatures.map((f) => generateFeatureCode(f)).join(`
|
|
45245
|
+
const newFeatureCode = newFeatures.map((f) => generateFeatureCode(f, newFeatureVarMap.get(f.id))).join(`
|
|
45213
45246
|
|
|
45214
45247
|
`);
|
|
45215
45248
|
if (lastFeatureBlockIndex >= 0) {
|
|
@@ -45249,7 +45282,7 @@ ${newFeatureCode}`);
|
|
|
45249
45282
|
}
|
|
45250
45283
|
const newPlans = plans.filter((p) => !matchedPlanIds.has(p.id));
|
|
45251
45284
|
if (newPlans.length > 0) {
|
|
45252
|
-
const newPlanCode = newPlans.map((p) => generatePlanCode(p, features,
|
|
45285
|
+
const newPlanCode = newPlans.map((p) => generatePlanCode(p, features, featureVarMap, newPlanVarMap.get(p.id))).join(`
|
|
45253
45286
|
|
|
45254
45287
|
`);
|
|
45255
45288
|
if (lastPlanBlockIndex >= 0) {
|
|
@@ -45307,19 +45340,20 @@ var init_inPlaceUpdate = __esm(() => {
|
|
|
45307
45340
|
// src/lib/transforms/sdkToCode/configFile.ts
|
|
45308
45341
|
function buildConfigFile(features, plans) {
|
|
45309
45342
|
const sections = [];
|
|
45343
|
+
const { featureVarMap, planVarMap } = resolveVarNames(features.map((f) => f.id), plans.map((p) => p.id));
|
|
45310
45344
|
sections.push(buildImports());
|
|
45311
45345
|
sections.push("");
|
|
45312
45346
|
if (features.length > 0) {
|
|
45313
45347
|
sections.push("// Features");
|
|
45314
45348
|
for (const feature of features) {
|
|
45315
|
-
sections.push(buildFeatureCode(feature));
|
|
45349
|
+
sections.push(buildFeatureCode(feature, featureVarMap.get(feature.id)));
|
|
45316
45350
|
sections.push("");
|
|
45317
45351
|
}
|
|
45318
45352
|
}
|
|
45319
45353
|
if (plans.length > 0) {
|
|
45320
45354
|
sections.push("// Plans");
|
|
45321
45355
|
for (const plan of plans) {
|
|
45322
|
-
sections.push(buildPlanCode(plan, features));
|
|
45356
|
+
sections.push(buildPlanCode(plan, features, featureVarMap, planVarMap.get(plan.id)));
|
|
45323
45357
|
sections.push("");
|
|
45324
45358
|
}
|
|
45325
45359
|
}
|
|
@@ -45519,7 +45553,7 @@ var init_pull = __esm(() => {
|
|
|
45519
45553
|
});
|
|
45520
45554
|
|
|
45521
45555
|
// src/lib/version.ts
|
|
45522
|
-
var APP_VERSION = "1.1.
|
|
45556
|
+
var APP_VERSION = "1.1.2";
|
|
45523
45557
|
|
|
45524
45558
|
// ../node_modules/.pnpm/@tanstack+query-core@5.90.17/node_modules/@tanstack/query-core/build/modern/subscribable.js
|
|
45525
45559
|
var Subscribable = class {
|