rman 0.12.1 → 0.13.0

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.
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.PublishCommand = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const package_json_1 = __importDefault(require("package-json"));
9
8
  const npmlog_1 = __importDefault(require("npmlog"));
10
9
  const command_1 = require("../core/command");
11
10
  const run_command_1 = require("./run-command");
12
11
  const path_1 = __importDefault(require("path"));
12
+ const npm_utils_1 = require("../utils/npm-utils");
13
13
  class PublishCommand extends run_command_1.RunCommand {
14
14
  constructor(repository, options) {
15
15
  super(repository, 'publish', options);
@@ -26,8 +26,9 @@ class PublishCommand extends run_command_1.RunCommand {
26
26
  }
27
27
  npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Fetching package information from repository`);
28
28
  try {
29
- const r = await (0, package_json_1.default)(p.json.name);
30
- if (r.version === p.version) {
29
+ const npmHelper = new npm_utils_1.NpmHelper({ cwd: p.dirname });
30
+ const r = await npmHelper.getPackageInfo(p.json.name);
31
+ if (r && r.version === p.version) {
31
32
  npmlog_1.default.info(this.commandName, logPkgName, npmlog_1.default.separator, `Ignored. Same version (${p.version}) in repository`);
32
33
  continue;
33
34
  }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.fsDelete = exports.tryStat = exports.fsExists = void 0;
6
+ exports.fsDelete = exports.fsReadFile = exports.tryStat = exports.fsExists = void 0;
7
7
  const promises_1 = __importDefault(require("fs/promises"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  async function fsExists(s) {
@@ -14,6 +14,7 @@ async function tryStat(s) {
14
14
  return promises_1.default.lstat(s).catch(() => undefined);
15
15
  }
16
16
  exports.tryStat = tryStat;
17
+ exports.fsReadFile = promises_1.default.readFile;
17
18
  async function fsDelete(fileOrDir) {
18
19
  const stat = await tryStat(fileOrDir);
19
20
  if (stat) {
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NpmHelper = exports.PackageNotFoundError = void 0;
4
+ const exec_1 = require("./exec");
5
+ class PackageNotFoundError extends Error {
6
+ }
7
+ exports.PackageNotFoundError = PackageNotFoundError;
8
+ class NpmHelper {
9
+ constructor(options) {
10
+ this.cwd = options?.cwd || process.cwd();
11
+ }
12
+ async getPackageInfo(packageName) {
13
+ const x = await (0, exec_1.exec)('npm', {
14
+ cwd: this.cwd,
15
+ argv: ['view', packageName, '--json']
16
+ });
17
+ if (x.stdout) {
18
+ if (x.stdout.includes('404'))
19
+ return new PackageNotFoundError('Package ' + packageName + ' not found in repository');
20
+ const b = x.stdout.indexOf('{');
21
+ const e = x.stdout.lastIndexOf('}');
22
+ const s = x.stdout.substring(b, e + 1);
23
+ try {
24
+ if (s)
25
+ return JSON.parse(s);
26
+ }
27
+ catch {
28
+ //
29
+ }
30
+ }
31
+ throw new Error('Unable to fetch version info');
32
+ }
33
+ }
34
+ exports.NpmHelper = NpmHelper;
@@ -1,9 +1,9 @@
1
1
  import chalk from 'chalk';
2
- import fetchPackageInfo from 'package-json';
3
2
  import logger from 'npmlog';
4
3
  import { Command } from './../core/command.mjs';
5
4
  import { RunCommand } from './run-command.mjs';
6
5
  import path from 'path';
6
+ import { NpmHelper } from './../utils/npm-utils.mjs';
7
7
  export class PublishCommand extends RunCommand {
8
8
  constructor(repository, options) {
9
9
  super(repository, 'publish', options);
@@ -20,8 +20,9 @@ export class PublishCommand extends RunCommand {
20
20
  }
21
21
  logger.info(this.commandName, logPkgName, logger.separator, `Fetching package information from repository`);
22
22
  try {
23
- const r = await fetchPackageInfo(p.json.name);
24
- if (r.version === p.version) {
23
+ const npmHelper = new NpmHelper({ cwd: p.dirname });
24
+ const r = await npmHelper.getPackageInfo(p.json.name);
25
+ if (r && r.version === p.version) {
25
26
  logger.info(this.commandName, logPkgName, logger.separator, `Ignored. Same version (${p.version}) in repository`);
26
27
  continue;
27
28
  }
@@ -1,5 +1,7 @@
1
1
  /// <reference types="node" />
2
+ import fsa from 'fs/promises';
2
3
  import { Stats } from 'node:fs';
3
4
  export declare function fsExists(s: string): Promise<boolean>;
4
5
  export declare function tryStat(s: any): Promise<Stats | undefined>;
6
+ export declare const fsReadFile: typeof fsa.readFile;
5
7
  export declare function fsDelete(fileOrDir: string): Promise<boolean>;
@@ -6,6 +6,7 @@ export async function fsExists(s) {
6
6
  export async function tryStat(s) {
7
7
  return fsa.lstat(s).catch(() => undefined);
8
8
  }
9
+ export const fsReadFile = fsa.readFile;
9
10
  export async function fsDelete(fileOrDir) {
10
11
  const stat = await tryStat(fileOrDir);
11
12
  if (stat) {
@@ -0,0 +1,12 @@
1
+ export declare class PackageNotFoundError extends Error {
2
+ }
3
+ export declare namespace NpmHelper {
4
+ }
5
+ export interface NpmOptions {
6
+ cwd?: string;
7
+ }
8
+ export declare class NpmHelper {
9
+ cwd: string;
10
+ constructor(options?: NpmOptions);
11
+ getPackageInfo(packageName: string): Promise<any>;
12
+ }
@@ -0,0 +1,29 @@
1
+ import { exec } from './exec.mjs';
2
+ export class PackageNotFoundError extends Error {
3
+ }
4
+ export class NpmHelper {
5
+ constructor(options) {
6
+ this.cwd = options?.cwd || process.cwd();
7
+ }
8
+ async getPackageInfo(packageName) {
9
+ const x = await exec('npm', {
10
+ cwd: this.cwd,
11
+ argv: ['view', packageName, '--json']
12
+ });
13
+ if (x.stdout) {
14
+ if (x.stdout.includes('404'))
15
+ return new PackageNotFoundError('Package ' + packageName + ' not found in repository');
16
+ const b = x.stdout.indexOf('{');
17
+ const e = x.stdout.lastIndexOf('}');
18
+ const s = x.stdout.substring(b, e + 1);
19
+ try {
20
+ if (s)
21
+ return JSON.parse(s);
22
+ }
23
+ catch {
24
+ //
25
+ }
26
+ }
27
+ throw new Error('Unable to fetch version info');
28
+ }
29
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rman",
3
3
  "description": "Monorepo repository manager",
4
- "version": "0.12.1",
4
+ "version": "0.13.0",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "contributors": [
@@ -38,10 +38,10 @@
38
38
  "envinfo": "^7.8.1",
39
39
  "fast-glob": "^3.2.11",
40
40
  "figures": "^4.0.0",
41
+ "ini": "^2.0.0",
41
42
  "is-ci": "^3.0.1",
42
43
  "js-yaml": "^4.1.0",
43
44
  "npmlog": "^6.0.1",
44
- "package-json": "^7.0.0",
45
45
  "path-key": "^4.0.0",
46
46
  "power-tasks": "^0.6.0",
47
47
  "putil-merge": "^3.8.0",
@@ -55,6 +55,7 @@
55
55
  "devDependencies": {
56
56
  "@babel/eslint-parser": "^7.17.0",
57
57
  "@types/envinfo": "^7.8.1",
58
+ "@types/ini": "^1.3.31",
58
59
  "@types/is-ci": "^3.0.0",
59
60
  "@types/jest": "^27.4.1",
60
61
  "@types/js-yaml": "^4.0.5",