Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: [joeldenning]
github: [jolyndenning]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective
ko_fi: # Replace with a single Ko-fi username
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "15"
- uses: pnpm/action-setup@v1.2.1
with:
version: 5.17.3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- run: pnpm test
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm exec pretty-quick --staged && pnpm test
pnpm exec pretty-quick --staged
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Joel Denning
Copyright (c) 2025 Jolyn Denning

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 6 additions & 6 deletions bin/narn.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env node
const { spawn } = require("child_process");
const {
import { spawn } from "node:child_process";
import {
detectYarn,
detectNpm,
detectPnpm,
getYarnArgs,
getNpmArgs,
} = require("../lib/narn-lib.js");
const fs = require("fs");
const path = require("path");
} from "../lib/narn-lib.js";
import fs from "fs";
import path from "path";

const narnPackageJson = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "../package.json"))
fs.readFileSync(path.resolve(import.meta.dirname, "../package.json")),
);

async function runPackageManager() {
Expand Down
2 changes: 1 addition & 1 deletion bin/narnx.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
const { spawn } = require("child_process");
import { spawn } from "child_process";

const narnxArgs = process.argv.slice(2);
let command;
Expand Down
38 changes: 20 additions & 18 deletions lib/narn-lib.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const fs = require("fs");
const path = require("path");
const minimist = require("minimist");
const validateNpmPackageName = require("validate-npm-package-name");
import fs from "fs";
import path from "path";
import minimist from "minimist";
import validateNpmPackageName from "validate-npm-package-name";

exports.detectYarn = function detectYarn(args) {
export function detectYarn(args) {
if (args && args.length > 0 && args[0] === "global") {
// all global commands go through default PM
return Promise.resolve(false);
Expand All @@ -14,13 +14,13 @@ exports.detectYarn = function detectYarn(args) {
fs.constants.F_OK,
(noYarnLock) => {
resolve(!Boolean(noYarnLock));
}
},
);
});
}
};
}

exports.detectPnpm = function detectNpm(args) {
export function detectPnpm(args) {
if (args && args.length > 0 && args[0] === "global") {
// all global commands go through default PM
return Promise.resolve(false);
Expand All @@ -31,13 +31,13 @@ exports.detectPnpm = function detectNpm(args) {
fs.constants.F_OK,
(noPnpmLock) => {
resolve(!Boolean(noPnpmLock));
}
},
);
});
}
};
}

exports.detectNpm = function detectNpm(args) {
export function detectNpm(args) {
if (args && args.length > 0 && args[0] === "global") {
// all global commands go through default PM
return Promise.resolve(false);
Expand All @@ -48,15 +48,17 @@ exports.detectNpm = function detectNpm(args) {
fs.constants.F_OK,
(noPackageLock) => {
resolve(!Boolean(noPackageLock));
}
},
);
});
}
};
}

exports.getYarnArgs = (narnArgs) => narnArgs;
export function getYarnArgs(narnArgs) {
return narnArgs;
}

exports.getNpmArgs = (narnArgs, isPnpm = false) => {
export function getNpmArgs(narnArgs, isPnpm = false) {
const yarnArgs = minimist(narnArgs, {
boolean: ["dev", "D", "latest", "frozen-lockfile"],
});
Expand Down Expand Up @@ -185,18 +187,18 @@ exports.getNpmArgs = (narnArgs, isPnpm = false) => {
}

return result || [npmTarget, ...npmArgs];
};
}

function transformNarnPackageString(packageToAdd) {
packageToAdd = packageToAdd.replace("file:", "");
const packageNameWithoutVersion = packageToAdd.slice(
0,
packageToAdd.indexOf("@") > 0
? packageToAdd.lastIndexOf("@")
: packageToAdd.length + 1
: packageToAdd.length + 1,
);
const isValidPackageName = validateNpmPackageName(
packageNameWithoutVersion
packageNameWithoutVersion,
).validForNewPackages;
if (isValidPackageName && packageNameWithoutVersion === packageToAdd) {
return `${packageToAdd}@latest`;
Expand Down
41 changes: 19 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
{
"name": "narn",
"version": "2.3.0",
"main": "lib/narn-lib.js",
"type": "module",
"exports": {
".": "./lib/narn-lib.js"
},
"packageManager": "pnpm@10.10.0",
"bin": {
"narn": "bin/narn.js",
"narnx": "bin/narnx.js"
},
"repository": "git@github.com:joeldenning/narn.git",
"author": "Joel Denning <joeldenning@gmail.com>",
"homepage": "https://github.com/joeldenning/narn",
"repository": "git@github.com:jolyndenning/narn.git",
"author": "Jolyn Denning <jolyndenning@gmail.com>",
"homepage": "https://github.com/jolyndenning/narn",
"license": "MIT",
"scripts": {
"test": "concurrently \"pnpm:test:*\"",
"test:jest": "jest --env=node",
"test:vitest": "vitest",
"test:lockfile": "js-correct-lockfile pnpm",
"format": "prettier . --write",
"check-format": "prettier . --check",
"postinstall": "husky install",
"prepublishOnly": "pinst --disable",
"postpublish": "pinst --enable"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
"prepare": "husky"
},
"files": [
"bin",
"lib"
],
"devDependencies": {
"@types/jest": "^27.4.1",
"concurrently": "^7.0.0",
"husky": "^7.0.4",
"jest": "^27.5.1",
"jest-cli": "^27.5.1",
"@types/jest": "^29.5.14",
"concurrently": "^9.1.2",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-cli": "^29.7.0",
"js-correct-lockfile": "^1.0.0",
"pinst": "^3.0.0",
"prettier": "^2.6.0",
"pretty-quick": "^3.1.3"
"prettier": "^3.5.3",
"pretty-quick": "^4.1.1",
"vitest": "^3.1.2"
},
"dependencies": {
"minimist": "^1.2.5",
"validate-npm-package-name": "^3.0.0"
"validate-npm-package-name": "^6.0.0"
}
}
Loading