Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

copypack

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copypack - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

dist/cli.d.ts

2

dist/copypack.d.ts
#!/usr/bin/env node
export {};
export declare function run(context: string, relativeProjectPath: string, sourcePackages: string[]): void;
//# sourceMappingURL=copypack.d.ts.map

@@ -5,49 +5,44 @@ #!/usr/bin/env node

import path from "node:path";
const [relativeProjectPath, ...sourcePackages] = ts.sys.args;
if (!relativeProjectPath) {
throw new Error("Missing relative project path");
}
if (!sourcePackages.length) {
sourcePackages.push("packages/*/package.json");
}
const targetProjectPath = path.resolve(relativeProjectPath);
const targetNodeModulesPath = validateProjectNoduleModules(targetProjectPath);
const packageJsonPaths = ts.sys.readDirectory(ts.sys.resolvePath("."), undefined, undefined, sourcePackages);
for (const filePath of packageJsonPaths) {
try {
const pkg = JSON.parse(ts.sys.readFile(filePath) || "null");
if (pkg) {
const dir = path.dirname(filePath);
console.log(pkg.name, dir);
const targetPackageLocation = path.join(targetNodeModulesPath, pkg.name);
if (fs.existsSync(targetPackageLocation) &&
fs.statSync(targetPackageLocation).isDirectory()) {
fs.rmdirSync(targetPackageLocation, { recursive: true });
fs.mkdirSync(targetPackageLocation, { recursive: true });
fs.cpSync(dir, targetPackageLocation, { recursive: true });
console.log("COPIED", pkg.name, "to target node_modules");
export function run(context, relativeProjectPath, sourcePackages) {
const targetProjectPath = path.join(context, relativeProjectPath);
const targetNodeModulesPath = validateProjectNoduleModules(targetProjectPath);
const packageJsonPaths = ts.sys.readDirectory(context, undefined, undefined, sourcePackages);
for (const filePath of packageJsonPaths) {
try {
const pkg = JSON.parse(ts.sys.readFile(filePath) || "null");
if (pkg) {
const dir = path.dirname(filePath);
console.log(pkg.name, dir);
const targetPackageLocation = path.join(targetNodeModulesPath, pkg.name);
if (fs.existsSync(targetPackageLocation) &&
fs.statSync(targetPackageLocation).isDirectory()) {
fs.rmSync(targetPackageLocation, { recursive: true });
fs.mkdirSync(targetPackageLocation, { recursive: true });
fs.cpSync(dir, targetPackageLocation, { recursive: true });
console.log("COPIED", pkg.name, "to target node_modules");
}
else {
console.log("SKIP", pkg.name, "does not exist in target node_modules");
}
}
else {
console.log("SKIP", pkg.name, "does not exist in target node_modules");
throw new Error(`package.json is empty`);
}
}
else {
throw new Error(`package.json is empty`);
catch (e) {
console.warn(`error while copying package: ${filePath}\n${e}\n\nSKIPPING.`, filePath, e);
}
}
catch (e) {
console.warn(`error while copying package: ${filePath}\n${e}\n\nSKIPPING.`, filePath, e);
}
}
function validateProjectNoduleModules(targetProjectPath) {
const targetNodeModules = path.join(targetProjectPath, "node_modules");
if (!fs.existsSync(targetNodeModules) ||
!fs.statSync(targetNodeModules).isDirectory()) {
throw new Error("node_modules does not exist or not a directory in: " + targetProjectPath);
if (fs.existsSync(targetNodeModules) &&
fs.statSync(targetNodeModules).isDirectory()) {
console.log("found target node_nodules:", targetNodeModules);
return targetNodeModules;
}
else {
console.log("target node_nodules:", targetNodeModules);
throw new Error("node_modules does not exist or not a directory in: " + targetProjectPath);
}
return targetNodeModules;
}
//# sourceMappingURL=copypack.js.map
{
"name": "copypack",
"version": "1.0.0",
"version": "1.0.1",
"description": "like links but copies",

@@ -8,3 +8,4 @@ "type": "module",

"scripts": {
"build": "tsc"
"build": "tsc",
"test": "node dist/copypack.test.js"
},

@@ -11,0 +12,0 @@ "keywords": [

@@ -6,49 +6,51 @@ #!/usr/bin/env node

const [relativeProjectPath, ...sourcePackages] = ts.sys.args;
export function run(
context: string,
relativeProjectPath: string,
sourcePackages: string[]
) {
const targetProjectPath = path.join(context, relativeProjectPath);
const targetNodeModulesPath = validateProjectNoduleModules(targetProjectPath);
const packageJsonPaths = ts.sys.readDirectory(
context,
undefined,
undefined,
sourcePackages
);
if (!relativeProjectPath) {
throw new Error("Missing relative project path");
}
if (!sourcePackages.length) {
sourcePackages.push("packages/*/package.json");
}
const targetProjectPath = path.resolve(relativeProjectPath);
const targetNodeModulesPath = validateProjectNoduleModules(targetProjectPath);
const packageJsonPaths = ts.sys.readDirectory(
ts.sys.resolvePath("."),
undefined,
undefined,
sourcePackages
);
for (const filePath of packageJsonPaths) {
try {
const pkg = JSON.parse(ts.sys.readFile(filePath) || "null");
if (pkg) {
const dir = path.dirname(filePath);
console.log(pkg.name, dir);
const targetPackageLocation = path.join(targetNodeModulesPath, pkg.name);
if (
fs.existsSync(targetPackageLocation) &&
fs.statSync(targetPackageLocation).isDirectory()
) {
fs.rmdirSync(targetPackageLocation, { recursive: true });
fs.mkdirSync(targetPackageLocation, { recursive: true });
fs.cpSync(dir, targetPackageLocation, { recursive: true });
console.log("COPIED", pkg.name, "to target node_modules");
for (const filePath of packageJsonPaths) {
try {
const pkg = JSON.parse(ts.sys.readFile(filePath) || "null");
if (pkg) {
const dir = path.dirname(filePath);
console.log(pkg.name, dir);
const targetPackageLocation = path.join(
targetNodeModulesPath,
pkg.name
);
if (
fs.existsSync(targetPackageLocation) &&
fs.statSync(targetPackageLocation).isDirectory()
) {
fs.rmSync(targetPackageLocation, { recursive: true });
fs.mkdirSync(targetPackageLocation, { recursive: true });
fs.cpSync(dir, targetPackageLocation, { recursive: true });
console.log("COPIED", pkg.name, "to target node_modules");
} else {
console.log(
"SKIP",
pkg.name,
"does not exist in target node_modules"
);
}
} else {
console.log("SKIP", pkg.name, "does not exist in target node_modules");
throw new Error(`package.json is empty`);
}
} else {
throw new Error(`package.json is empty`);
} catch (e) {
console.warn(
`error while copying package: ${filePath}\n${e}\n\nSKIPPING.`,
filePath,
e
);
}
} catch (e) {
console.warn(
`error while copying package: ${filePath}\n${e}\n\nSKIPPING.`,
filePath,
e
);
}

@@ -60,12 +62,12 @@ }

if (
!fs.existsSync(targetNodeModules) ||
!fs.statSync(targetNodeModules).isDirectory()
fs.existsSync(targetNodeModules) &&
fs.statSync(targetNodeModules).isDirectory()
) {
console.log("found target node_nodules:", targetNodeModules);
return targetNodeModules;
} else {
throw new Error(
"node_modules does not exist or not a directory in: " + targetProjectPath
);
} else {
console.log("target node_nodules:", targetNodeModules);
}
return targetNodeModules;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc