kalup 0.1.0 → 0.1.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/README.md
CHANGED
|
@@ -7,10 +7,13 @@ Kalup keeps a HubSpot portal's properties, property groups and custom object sch
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npm install
|
|
10
|
+
npm install @kalup/core
|
|
11
|
+
npm install -D kalup
|
|
11
12
|
```
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
With pnpm, yarn or bun: `pnpm add @kalup/core && pnpm add -D kalup`, and the same with `yarn add` or `bun add`.
|
|
15
|
+
|
|
16
|
+
Node 22.13.1 or later. Your app imports `@kalup/core` at run time (7 kB, no dependencies), so it is a regular dependency. The `kalup` CLI is a dev tool. If you skip the first line, `kalup init` adds `@kalup/core` to `package.json` for you.
|
|
14
17
|
|
|
15
18
|
## First run
|
|
16
19
|
|
|
@@ -14731,6 +14731,29 @@ const BIOME_IGNORES = [
|
|
|
14731
14731
|
"!!.kalup/**"
|
|
14732
14732
|
]]
|
|
14733
14733
|
];
|
|
14734
|
+
const CORE = "@kalup/core";
|
|
14735
|
+
/** The dependency lists that count as having @kalup/core already. */
|
|
14736
|
+
const DEPENDENCY_LISTS = [
|
|
14737
|
+
"dependencies",
|
|
14738
|
+
"devDependencies",
|
|
14739
|
+
"peerDependencies"
|
|
14740
|
+
];
|
|
14741
|
+
/** The first lockfile found names the package manager. */
|
|
14742
|
+
const LOCKFILES = [
|
|
14743
|
+
["pnpm-lock.yaml", "pnpm"],
|
|
14744
|
+
["yarn.lock", "yarn"],
|
|
14745
|
+
["bun.lock", "bun"],
|
|
14746
|
+
["bun.lockb", "bun"],
|
|
14747
|
+
["package-lock.json", "npm"]
|
|
14748
|
+
];
|
|
14749
|
+
const MANAGERS = [
|
|
14750
|
+
"npm",
|
|
14751
|
+
"pnpm",
|
|
14752
|
+
"yarn",
|
|
14753
|
+
"bun"
|
|
14754
|
+
];
|
|
14755
|
+
/** A directory with one of these is the top of the project or workspace: the lockfile search stops there. */
|
|
14756
|
+
const PROJECT_ROOTS = [".git", "pnpm-workspace.yaml"];
|
|
14734
14757
|
const DEFAULT_OBJECTS = [
|
|
14735
14758
|
"contacts",
|
|
14736
14759
|
"companies",
|
|
@@ -14749,6 +14772,7 @@ const AGENTS_BLOCK = /<!-- kalup:start/;
|
|
|
14749
14772
|
const CLAUDE_POINTER = /@AGENTS\.md/;
|
|
14750
14773
|
const LINE_INDENT = /\r?\n[ \t]*$/;
|
|
14751
14774
|
const LINE_BREAK = /\r?\n/;
|
|
14775
|
+
const JSON_INDENT = /^([ \t]+)"/m;
|
|
14752
14776
|
async function init(ctx) {
|
|
14753
14777
|
const { cwd, flags } = ctx;
|
|
14754
14778
|
const portalId = parsePortal$1(flags.portal);
|
|
@@ -14791,6 +14815,7 @@ async function init(ctx) {
|
|
|
14791
14815
|
if (kalup || env) files.push(".gitignore");
|
|
14792
14816
|
const note = ignoreInFormatter(cwd, biome, files);
|
|
14793
14817
|
writeAgentFiles(cwd, files);
|
|
14818
|
+
const core = addCore(cwd, files);
|
|
14794
14819
|
let pulled;
|
|
14795
14820
|
try {
|
|
14796
14821
|
pulled = await pull({
|
|
@@ -14824,7 +14849,8 @@ async function init(ctx) {
|
|
|
14824
14849
|
scopes,
|
|
14825
14850
|
recommended,
|
|
14826
14851
|
writeScopes,
|
|
14827
|
-
files
|
|
14852
|
+
files,
|
|
14853
|
+
packageJson: core.data
|
|
14828
14854
|
};
|
|
14829
14855
|
const lines = [
|
|
14830
14856
|
`Portal ${portalId}: ${account.accountType}, ${account.uiDomain}, ${account.timeZone}`,
|
|
@@ -14838,6 +14864,7 @@ async function init(ctx) {
|
|
|
14838
14864
|
...files.map((file) => `wrote ${file}`),
|
|
14839
14865
|
...note === void 0 ? [] : [note]
|
|
14840
14866
|
];
|
|
14867
|
+
const next = core.next === void 0 ? "" : `${core.next}\n`;
|
|
14841
14868
|
if (pulled instanceof KalupError) {
|
|
14842
14869
|
const retry = {
|
|
14843
14870
|
code: "E_FIRST_PULL",
|
|
@@ -14847,7 +14874,7 @@ async function init(ctx) {
|
|
|
14847
14874
|
return {
|
|
14848
14875
|
data,
|
|
14849
14876
|
issues: [...pulled.issues, retry],
|
|
14850
|
-
text: `${lines.join("\n")}\n`,
|
|
14877
|
+
text: `${lines.join("\n")}\n${next}`,
|
|
14851
14878
|
exitCode: pulled.exitCode
|
|
14852
14879
|
};
|
|
14853
14880
|
}
|
|
@@ -14855,7 +14882,7 @@ async function init(ctx) {
|
|
|
14855
14882
|
return {
|
|
14856
14883
|
data,
|
|
14857
14884
|
issues: [...largeScope(pulled.data), ...pulled.issues ?? []],
|
|
14858
|
-
text: `${lines.join("\n")}\n${pulled.text ?? ""}`,
|
|
14885
|
+
text: `${lines.join("\n")}\n${pulled.text ?? ""}${next}`,
|
|
14859
14886
|
exitCode: pulled.exitCode
|
|
14860
14887
|
};
|
|
14861
14888
|
}
|
|
@@ -14914,6 +14941,82 @@ function ignoreInFormatter(cwd, biome, files) {
|
|
|
14914
14941
|
files.push(biome.file);
|
|
14915
14942
|
}
|
|
14916
14943
|
}
|
|
14944
|
+
/**
|
|
14945
|
+
* @kalup/core added to dependencies in package.json when no dependency list has it, as the files under kalup/ import it
|
|
14946
|
+
* at runtime. The file keeps its indentation, key order and final line break; dependencies are sorted, as npm keeps
|
|
14947
|
+
* them. Adds package.json to `files` when it wrote. `next` is the install step to print, when there is one.
|
|
14948
|
+
*/
|
|
14949
|
+
function addCore(cwd, files) {
|
|
14950
|
+
const manager = packageManager(cwd);
|
|
14951
|
+
const install = `${manager === "npm" ? "npm install" : `${manager} add`} ${CORE}`;
|
|
14952
|
+
const path = join(cwd, "package.json");
|
|
14953
|
+
if (!existsSync(path)) return {
|
|
14954
|
+
data: {
|
|
14955
|
+
added: false,
|
|
14956
|
+
found: false,
|
|
14957
|
+
manager
|
|
14958
|
+
},
|
|
14959
|
+
next: `No package.json here. The files under kalup/ import ${CORE}: install it in your app with ${install}.`
|
|
14960
|
+
};
|
|
14961
|
+
const text = readFileSync(path, "utf8");
|
|
14962
|
+
const pkg = parseJson(text);
|
|
14963
|
+
if (pkg instanceof Error || !isObject(pkg) || !DEPENDENCY_LISTS.every((field) => pkg[field] === void 0 || isObject(pkg[field]))) return {
|
|
14964
|
+
data: {
|
|
14965
|
+
added: false,
|
|
14966
|
+
found: true,
|
|
14967
|
+
manager
|
|
14968
|
+
},
|
|
14969
|
+
next: `package.json was left alone: init could not read its dependencies. Install ${CORE} in your app with ${install}.`
|
|
14970
|
+
};
|
|
14971
|
+
if (DEPENDENCY_LISTS.some((field) => isObject(pkg[field]) && Object.hasOwn(pkg[field], CORE))) return { data: {
|
|
14972
|
+
added: false,
|
|
14973
|
+
found: true,
|
|
14974
|
+
manager
|
|
14975
|
+
} };
|
|
14976
|
+
const dependencies = {
|
|
14977
|
+
...pkg.dependencies,
|
|
14978
|
+
[CORE]: `^${version}`
|
|
14979
|
+
};
|
|
14980
|
+
pkg.dependencies = Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) => a.localeCompare(b, "en")));
|
|
14981
|
+
const eol = text.includes("\r\n") ? "\r\n" : "\n";
|
|
14982
|
+
const json = JSON.stringify(pkg, null, JSON_INDENT.exec(text)?.[1] ?? " ").replaceAll("\n", eol);
|
|
14983
|
+
writeFileSync(path, `${json}${text.endsWith("\n") ? eol : ""}`);
|
|
14984
|
+
files.push("package.json");
|
|
14985
|
+
return {
|
|
14986
|
+
data: {
|
|
14987
|
+
added: true,
|
|
14988
|
+
found: true,
|
|
14989
|
+
manager
|
|
14990
|
+
},
|
|
14991
|
+
next: `Added ${CORE} to dependencies in package.json: run ${manager} install.`
|
|
14992
|
+
};
|
|
14993
|
+
}
|
|
14994
|
+
function isObject(value) {
|
|
14995
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14996
|
+
}
|
|
14997
|
+
function packageManager(cwd) {
|
|
14998
|
+
const dirs = projectDirs(cwd);
|
|
14999
|
+
for (const dir of dirs) {
|
|
15000
|
+
const lock = LOCKFILES.find(([file]) => existsSync(join(dir, file)));
|
|
15001
|
+
if (lock !== void 0) return lock[1];
|
|
15002
|
+
}
|
|
15003
|
+
for (const dir of dirs) {
|
|
15004
|
+
const pkg = parseJson(existsSync(join(dir, "package.json")) ? readFileSync(join(dir, "package.json"), "utf8") : "");
|
|
15005
|
+
const field = isObject(pkg) && typeof pkg.packageManager === "string" ? pkg.packageManager.split("@")[0] : void 0;
|
|
15006
|
+
if (field !== void 0 && MANAGERS.includes(field)) return field;
|
|
15007
|
+
}
|
|
15008
|
+
const agent = process.env.npm_config_user_agent?.split("/")[0] ?? "";
|
|
15009
|
+
return MANAGERS.includes(agent) ? agent : "npm";
|
|
15010
|
+
}
|
|
15011
|
+
function projectDirs(cwd) {
|
|
15012
|
+
const dirs = [cwd];
|
|
15013
|
+
let dir = cwd;
|
|
15014
|
+
while (!PROJECT_ROOTS.some((name) => existsSync(join(dir, name))) && dirname(dir) !== dir) {
|
|
15015
|
+
dir = dirname(dir);
|
|
15016
|
+
dirs.push(dir);
|
|
15017
|
+
}
|
|
15018
|
+
return dirs;
|
|
15019
|
+
}
|
|
14917
15020
|
function writeAgentFiles(cwd, files) {
|
|
14918
15021
|
if (append(cwd, "AGENTS.md", agentsBlock, AGENTS_BLOCK, true)) files.push("AGENTS.md");
|
|
14919
15022
|
const claude = join(cwd, "CLAUDE.md");
|
package/dist/commands.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as TargetRebindCommand, a as CompareCommand, c as InitCommand, d as PlanCommand, f as PullCommand, g as StatusCommand, h as StateRebuildCommand, i as COMMANDS, l as IrCommand, m as SnapshotCommand, n as ApplyCommand, o as DocsCommand, p as RmCommand, r as BlueprintUpgradeCommand, s as FmtCommand, t as AddCommand, u as KalupCommand, v as ValidateCommand } from "./commands-
|
|
1
|
+
import { _ as TargetRebindCommand, a as CompareCommand, c as InitCommand, d as PlanCommand, f as PullCommand, g as StatusCommand, h as StateRebuildCommand, i as COMMANDS, l as IrCommand, m as SnapshotCommand, n as ApplyCommand, o as DocsCommand, p as RmCommand, r as BlueprintUpgradeCommand, s as FmtCommand, t as AddCommand, u as KalupCommand, v as ValidateCommand } from "./commands-BpQ20pA7.mjs";
|
|
2
2
|
export { AddCommand, ApplyCommand, BlueprintUpgradeCommand, COMMANDS, CompareCommand, DocsCommand, FmtCommand, InitCommand, IrCommand, KalupCommand, PlanCommand, PullCommand, RmCommand, SnapshotCommand, StateRebuildCommand, StatusCommand, TargetRebindCommand, ValidateCommand };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as sanitize, C as usageError, D as disclaimer, E as bin, O as escapeJson, S as versionText, T as KalupError, b as formats, k as exitCodes, u as KalupCommand, w as IssueError, x as version, y as PATH_MAX } from "./commands-
|
|
1
|
+
import { A as sanitize, C as usageError, D as disclaimer, E as bin, O as escapeJson, S as versionText, T as KalupError, b as formats, k as exitCodes, u as KalupCommand, w as IssueError, x as version, y as PATH_MAX } from "./commands-BpQ20pA7.mjs";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
package/dist/host.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as isInteractive, r as run, t as execute } from "./host-
|
|
1
|
+
import { n as isInteractive, r as run, t as execute } from "./host-CcBOCkff.mjs";
|
|
2
2
|
export { execute, isInteractive, run };
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kalup",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Configuration as code for HubSpot: pull, compare, plan and apply properties and property groups",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hubspot",
|
|
@@ -63,13 +63,13 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@oclif/core": "^5.0.0",
|
|
66
|
-
"@kalup/core": "0.1.
|
|
66
|
+
"@kalup/core": "0.1.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"tsdown": "^0.23.0",
|
|
70
70
|
"vitest": "^5.0.1",
|
|
71
|
-
"@kalup/
|
|
72
|
-
"@kalup/
|
|
71
|
+
"@kalup/engine": "0.0.0",
|
|
72
|
+
"@kalup/tsconfig": "0.0.0"
|
|
73
73
|
},
|
|
74
74
|
"engines": {
|
|
75
75
|
"node": ">=22.13.1"
|