framer-code-link 0.21.0-alpha.3 → 0.21.0-alpha.4
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.mjs +7 -16
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,6 @@ import { createHash as createHash$1 } from "crypto";
|
|
|
16
16
|
import { execSync } from "child_process";
|
|
17
17
|
import fs$2 from "fs";
|
|
18
18
|
import { setupTypeAcquisition } from "@typescript/ata";
|
|
19
|
-
import { parseImports } from "parse-imports";
|
|
20
19
|
import ts from "typescript";
|
|
21
20
|
import { fileURLToPath } from "node:url";
|
|
22
21
|
import chokidar from "chokidar";
|
|
@@ -1515,7 +1514,7 @@ var Installer = class {
|
|
|
1515
1514
|
for (const file of files) {
|
|
1516
1515
|
if (!file.content || JSON_EXTENSION_REGEX.test(file.name)) continue;
|
|
1517
1516
|
try {
|
|
1518
|
-
const imports =
|
|
1517
|
+
const imports = extractNpmPackageNames(file.content);
|
|
1519
1518
|
for (const packageName of imports) packageNames.add(packageName);
|
|
1520
1519
|
} catch (err) {
|
|
1521
1520
|
debug(`Type installer failed to parse imports for ${file.name}`, err);
|
|
@@ -1797,16 +1796,15 @@ function getBasePackageName(packageName) {
|
|
|
1797
1796
|
if (packageName.startsWith("@")) return parts.length >= 2 ? parts.slice(0, 2).join("/") : packageName;
|
|
1798
1797
|
return parts[0] ?? packageName;
|
|
1799
1798
|
}
|
|
1800
|
-
|
|
1801
|
-
const
|
|
1799
|
+
function extractNpmPackageNames(code) {
|
|
1800
|
+
const { importedFiles } = ts.preProcessFile(code, true, true);
|
|
1802
1801
|
const seen = /* @__PURE__ */ new Set();
|
|
1803
|
-
for (const
|
|
1804
|
-
const specifier = imported.moduleSpecifier;
|
|
1805
|
-
if (specifier.type !== "package" || !specifier.isConstant || !specifier.value) continue;
|
|
1806
|
-
seen.add(getBasePackageName(specifier.value));
|
|
1807
|
-
}
|
|
1802
|
+
for (const { fileName } of importedFiles) if (isPackageSpecifier(fileName)) seen.add(getBasePackageName(fileName));
|
|
1808
1803
|
return [...seen];
|
|
1809
1804
|
}
|
|
1805
|
+
function isPackageSpecifier(specifier) {
|
|
1806
|
+
return !specifier.startsWith(".") && !specifier.startsWith("/") && !/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(specifier);
|
|
1807
|
+
}
|
|
1810
1808
|
function sortDependencyMap(dependencies) {
|
|
1811
1809
|
return Object.fromEntries(Object.entries(dependencies).sort(([a], [b]) => a.localeCompare(b)));
|
|
1812
1810
|
}
|
|
@@ -3991,13 +3989,6 @@ function parseUnsupportedNpmMode(mode) {
|
|
|
3991
3989
|
if (mode === "acquire-types" || mode === "package-manager") return mode;
|
|
3992
3990
|
throw new InvalidArgumentError("unsupported npm mode must be 'acquire-types' or 'package-manager'");
|
|
3993
3991
|
}
|
|
3994
|
-
program.exitOverride((err) => {
|
|
3995
|
-
if (err.code === "commander.missingArgument") {
|
|
3996
|
-
console.error("Missing Project ID. Copy command via Code Link Plugin.");
|
|
3997
|
-
process.exit(err.exitCode);
|
|
3998
|
-
}
|
|
3999
|
-
throw err;
|
|
4000
|
-
});
|
|
4001
3992
|
program.name("framer-code-link").description("Sync Framer code components to your local filesystem").version(version).argument("[projectHash]", "Framer Project ID Hash (auto-detected from package.json if omitted)").option("-n, --name <name>", "Project name (optional)").option("-d, --dir <directory>", "Explicit project directory").option("--once", "Exit after the initial sync completes").option("-v, --verbose", "Enable verbose logging").option("--log-level <level>", "Set log level (debug, info, warn, error)").option("--dangerously-auto-delete", "Automatically delete remote files without confirmation").addOption(new Option("--unsupported-npm [mode]", "Handle unsupported npm packages (default without mode: acquire-types; modes: acquire-types, package-manager)").argParser(parseUnsupportedNpmMode).preset("acquire-types")).action(async (projectHash, options) => {
|
|
4002
3993
|
if (!projectHash) {
|
|
4003
3994
|
const detected = await getProjectHashFromCwd();
|
package/package.json
CHANGED