Skip to content

Commit

Permalink
fix(npm): bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Airkro committed Dec 18, 2023
1 parent 978f75a commit 21721ed
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 77 deletions.
93 changes: 53 additions & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
],
"devDependencies": {
"@nice-move/cli": "^0.11.1",
"@nice-move/eslint-config-base": "^0.9.25",
"@nice-move/prettier-config": "^0.9.9",
"@nice-move/eslint-config-base": "^0.10.0",
"@nice-move/prettier-config": "^0.10.0",
"best-shot": "^0.4.6",
"eslint": "^8.55.0",
"eslint": "^8.56.0",
"garou": "^0.6.20",
"prettier": "^3.1.1"
},
"engines": {
"node": "^18.0.0 || ^20.0.0",
"npm": ">=9.4.0"
},
"packageManager": "[email protected].4",
"packageManager": "[email protected].5",
"eslintConfig": {
"extends": "@nice-move/eslint-config-base"
},
Expand Down
21 changes: 1 addition & 20 deletions packages/npm/lib/npm/filter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import validate from 'validate-npm-package-name';

import { logger } from './logger.mjs';

export function filter(pkg, env) {
export function filter(pkg) {
if (pkg.private) {
logger.info('[package is private]', pkg.name);

Expand Down Expand Up @@ -55,24 +55,5 @@ export function filter(pkg, env) {
}
}

const { packageManager } = pkg;

if (pkg.engines?.[packageManager]) {
if (!semver.validRange(pkg.engines[packageManager])) {
logger.warn(`[pkg.engines.${packageManager} isn't valid]`, pkg.pkg);

return false;
}

if (
env.packageManager.version &&
!semver.satisfies(env.packageManager.version, pkg.engines[packageManager])
) {
logger.warn(`[pkg.engines.${packageManager} isn't match]`, pkg.pkg);

return false;
}
}

return true;
}
4 changes: 0 additions & 4 deletions packages/npm/lib/npm/git.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ async function doAction(condition, okay, fail) {
return false;
}

export async function packageManagerVersion(packageManager = 'npm') {
return Exec(packageManager, ['-v']);
}

export function gitSupport() {
return doAction(
Git('--version').then(Boolean),
Expand Down
10 changes: 2 additions & 8 deletions packages/npm/lib/npm/scan.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { readFile } from 'node:fs/promises';
import { dirname } from 'node:path';

import { filter } from './filter.mjs';
import {
getFileContentFromLastCommit,
getLastCommitFiles,
packageManagerVersion,
} from './git.mjs';
import { getFileContentFromLastCommit, getLastCommitFiles } from './git.mjs';
import { logger } from './logger.mjs';
import { readNpmToken } from './token.mjs';

Expand Down Expand Up @@ -66,9 +62,7 @@ async function publishReady(list) {
for (const item of list) {
const okay = await readJSON(item);

const version = await packageManagerVersion(okay.packageManager);

if (okay && filter(okay, { packageManager: { version } })) {
if (okay && filter(okay)) {
io.push(okay);
logger.okay('[Publish Allowed]', okay.name);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bring-it/npm",
"version": "0.4.1",
"version": "0.4.2",
"description": "Publish npm packages when needed",
"license": "MIT",
"author": {
Expand Down

0 comments on commit 21721ed

Please sign in to comment.