symlx 0.1.3 → 0.1.5
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 +279 -1
- package/dist/cli.js +17 -9
- package/dist/commands/link.js +66 -0
- package/dist/commands/serve copy.js +169 -0
- package/dist/commands/serve.js +37 -67
- package/dist/commands/serve_stash.js +169 -0
- package/dist/lib/bin-targets.js +98 -0
- package/dist/lib/constants.js +4 -0
- package/dist/{services → lib}/link-manager.js +37 -18
- package/dist/lib/link-result.js +22 -0
- package/dist/lib/options.js +120 -26
- package/dist/lib/schema.js +40 -21
- package/dist/lib/serve-runtime.js +81 -0
- package/dist/{services → lib}/session-store.js +54 -25
- package/dist/lib/utils.js +107 -4
- package/dist/lib/{validate.js → validator.js} +15 -5
- package/dist/options.js +37 -0
- package/dist/postinstall.js +142 -0
- package/dist/preinstall.js +10 -0
- package/dist/ui/{collision-prompt.js → prompts.js} +2 -2
- package/dist/ui/serve-output.js +55 -0
- package/package.json +8 -4
- package/dist/core/paths.js +0 -32
- package/dist/core/types.js +0 -2
- package/dist/lib/paths.js +0 -26
- package/dist/lib/validators.js +0 -29
- package/dist/services/package-bins.js +0 -62
- /package/dist/{services → lib}/lifecycle.js +0 -0
package/dist/core/paths.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSymlxPaths = getSymlxPaths;
|
|
7
|
-
exports.pathContainsDir = pathContainsDir;
|
|
8
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
9
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
// Central place for runtime paths so every command/service resolves locations consistently.
|
|
11
|
-
function getSymlxPaths(customBinDir) {
|
|
12
|
-
// symlx keeps mutable runtime state under the user's home directory.
|
|
13
|
-
const rootSymlxDir = node_path_1.default.join(node_os_1.default.homedir(), '.symlx');
|
|
14
|
-
// Commands are linked here unless the caller overrides with --bin-dir.
|
|
15
|
-
const binDir = customBinDir
|
|
16
|
-
? node_path_1.default.resolve(customBinDir)
|
|
17
|
-
: node_path_1.default.join(rootSymlxDir, 'bin');
|
|
18
|
-
// Session files live separately from bins and are used for stale cleanup.
|
|
19
|
-
const sessionDir = node_path_1.default.join(rootSymlxDir, 'sessions');
|
|
20
|
-
return { binDir, sessionDir };
|
|
21
|
-
}
|
|
22
|
-
// Checks if PATH already contains a directory so we can avoid noisy setup hints.
|
|
23
|
-
function pathContainsDir(currentPath, targetDir) {
|
|
24
|
-
if (!currentPath) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
const resolvedTarget = node_path_1.default.resolve(targetDir);
|
|
28
|
-
const parts = currentPath
|
|
29
|
-
.split(node_path_1.default.delimiter)
|
|
30
|
-
.map((item) => node_path_1.default.resolve(item));
|
|
31
|
-
return parts.includes(resolvedTarget);
|
|
32
|
-
}
|
package/dist/core/types.js
DELETED
package/dist/lib/paths.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSymlxPaths = getSymlxPaths;
|
|
7
|
-
exports.pathContainsDir = pathContainsDir;
|
|
8
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
9
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
function getSymlxPaths(binDir) {
|
|
11
|
-
// Keep mutable runtime state under the user's home directory.
|
|
12
|
-
// Session files live separately from bins and are used for stale cleanup.
|
|
13
|
-
const sessionDir = node_path_1.default.join(node_os_1.default.homedir(), '.symlx', 'sessions');
|
|
14
|
-
return { binDir, sessionDir };
|
|
15
|
-
}
|
|
16
|
-
// Checks if PATH already contains a directory so we can avoid noisy setup hints.
|
|
17
|
-
function pathContainsDir(currentPath, targetDir) {
|
|
18
|
-
if (!currentPath) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
const resolvedTarget = node_path_1.default.resolve(targetDir);
|
|
22
|
-
const parts = currentPath
|
|
23
|
-
.split(node_path_1.default.delimiter)
|
|
24
|
-
.map((item) => node_path_1.default.resolve(item));
|
|
25
|
-
return parts.includes(resolvedTarget);
|
|
26
|
-
}
|
package/dist/lib/validators.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serveOptionsSchema = exports.collisionPolicySchema = void 0;
|
|
4
|
-
exports.validate = validate;
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
const collisionPolicySchema = zod_1.z.enum(['prompt', 'skip', 'fail', 'overwrite']);
|
|
7
|
-
exports.collisionPolicySchema = collisionPolicySchema;
|
|
8
|
-
const serveOptionsSchema = zod_1.z.object({
|
|
9
|
-
binDir: zod_1.z.string().trim().min(1).optional(),
|
|
10
|
-
collision: collisionPolicySchema,
|
|
11
|
-
nonInteractive: zod_1.z.boolean(),
|
|
12
|
-
});
|
|
13
|
-
exports.serveOptionsSchema = serveOptionsSchema;
|
|
14
|
-
function formatIssues(error) {
|
|
15
|
-
const details = error.issues
|
|
16
|
-
.map((issue) => {
|
|
17
|
-
const pathLabel = issue.path.length > 0 ? issue.path.join('.') : 'value';
|
|
18
|
-
return `${pathLabel}: ${issue.message}`;
|
|
19
|
-
})
|
|
20
|
-
.join('; ');
|
|
21
|
-
return details || 'invalid input';
|
|
22
|
-
}
|
|
23
|
-
function validate(schema, input, label = 'input') {
|
|
24
|
-
const result = schema.safeParse(input);
|
|
25
|
-
if (!result.success) {
|
|
26
|
-
throw new Error(`invalid ${label}: ${formatIssues(result.error)}`);
|
|
27
|
-
}
|
|
28
|
-
return result.data;
|
|
29
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.loadPackageJSONOptions = loadPackageJSONOptions;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const utils_1 = require("../lib/utils");
|
|
10
|
-
// npm allows `bin` as a string; in that form the command name defaults to package name
|
|
11
|
-
// (without scope for scoped packages).
|
|
12
|
-
function inferBinName(packageName) {
|
|
13
|
-
if (!packageName) {
|
|
14
|
-
return undefined;
|
|
15
|
-
}
|
|
16
|
-
if (packageName.startsWith('@')) {
|
|
17
|
-
const parts = packageName.split('/');
|
|
18
|
-
if (parts.length !== 2 || !parts[1]) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
return parts[1];
|
|
22
|
-
}
|
|
23
|
-
return packageName;
|
|
24
|
-
}
|
|
25
|
-
// Loads and validates all bin entries for the current project.
|
|
26
|
-
// Returned map is command name => absolute target file path.
|
|
27
|
-
function loadPackageJSONOptions(cwd) {
|
|
28
|
-
const packageJsonPath = node_path_1.default.join(cwd, 'package.json');
|
|
29
|
-
if (!node_fs_1.default.existsSync(packageJsonPath)) {
|
|
30
|
-
return {
|
|
31
|
-
bin: {},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const packageJson = (0, utils_1.loadJSONFile)(packageJsonPath);
|
|
35
|
-
if (!packageJson || !packageJson.bin) {
|
|
36
|
-
return {
|
|
37
|
-
bin: {},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
const bins = {};
|
|
41
|
-
if (typeof packageJson.bin === 'string') {
|
|
42
|
-
const inferredBinName = inferBinName(packageJson.name);
|
|
43
|
-
if (inferredBinName) {
|
|
44
|
-
bins[inferredBinName] = node_path_1.default.resolve(cwd, packageJson.bin);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
for (const [name, relTarget] of Object.entries(packageJson.bin)) {
|
|
49
|
-
bins[name] = node_path_1.default.resolve(cwd, relTarget);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// if (bins.size === 0) {
|
|
53
|
-
// throw new Error('no bin entries found');
|
|
54
|
-
// }
|
|
55
|
-
// // Fail fast if package.json points to non-existing executables.
|
|
56
|
-
// for (const [name, target] of bins.entries()) {
|
|
57
|
-
// if (!fs.existsSync(target)) {
|
|
58
|
-
// throw new Error(`bin target for "${name}" does not exist: ${target}`);
|
|
59
|
-
// }
|
|
60
|
-
// }
|
|
61
|
-
return { bin: {} };
|
|
62
|
-
}
|
|
File without changes
|