@react-native-community/cli-tools
Advanced tools
Comparing version 11.0.0-alpha.2 to 11.0.0
@@ -8,3 +8,8 @@ /** | ||
} | ||
/** | ||
* Raised when we're unable to find a package.json | ||
*/ | ||
export declare class UnknownProjectError extends Error { | ||
} | ||
export declare const inlineString: (str: string) => string; | ||
//# sourceMappingURL=errors.d.ts.map |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.inlineString = exports.CLIError = void 0; | ||
exports.inlineString = exports.UnknownProjectError = exports.CLIError = void 0; | ||
/** | ||
@@ -25,3 +25,9 @@ * A custom Error that creates a single-lined message to match current styling inside CLI. | ||
} | ||
/** | ||
* Raised when we're unable to find a package.json | ||
*/ | ||
exports.CLIError = CLIError; | ||
class UnknownProjectError extends Error {} | ||
exports.UnknownProjectError = UnknownProjectError; | ||
const inlineString = str => str.replace(/(\s{2,})/gm, ' ').trim(); | ||
@@ -28,0 +34,0 @@ exports.inlineString = inlineString; |
@@ -7,3 +7,3 @@ import { RequestInit as FetchOptions, Request, Headers } from 'node-fetch'; | ||
declare const fetchToTemp: (url: string) => Promise<string>; | ||
declare const fetch: (url: string | Request, options?: FetchOptions | undefined) => Promise<{ | ||
declare const fetch: (url: string | Request, options?: FetchOptions) => Promise<{ | ||
status: number; | ||
@@ -10,0 +10,0 @@ data: any; |
@@ -16,3 +16,3 @@ /** | ||
*/ | ||
export declare type PackageRef = { | ||
export type PackageRef = { | ||
scope?: string; | ||
@@ -24,3 +24,3 @@ name: string; | ||
*/ | ||
export declare type FindPackageDependencyOptions = { | ||
export type FindPackageDependencyOptions = { | ||
/** | ||
@@ -27,0 +27,0 @@ * Optional starting directory for the search. Defaults to `process.cwd()`. |
@@ -8,3 +8,3 @@ export { default as logger } from './logger'; | ||
export { default as launchEditor } from './launchEditor'; | ||
export { default as releaseChecker } from './releaseChecker'; | ||
export * as version from './releaseChecker'; | ||
export { default as resolveNodeModuleDir } from './resolveNodeModuleDir'; | ||
@@ -15,3 +15,4 @@ export { default as hookStdout } from './hookStdout'; | ||
export { default as printRunDoctorTip } from './printRunDoctorTip'; | ||
export * as link from './doclink'; | ||
export * from './errors'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -15,3 +15,3 @@ "use strict"; | ||
launchEditor: true, | ||
releaseChecker: true, | ||
version: true, | ||
resolveNodeModuleDir: true, | ||
@@ -23,3 +23,4 @@ hookStdout: true, | ||
findProjectRoot: true, | ||
printRunDoctorTip: true | ||
printRunDoctorTip: true, | ||
link: true | ||
}; | ||
@@ -98,2 +99,3 @@ Object.defineProperty(exports, "Loader", { | ||
}); | ||
exports.link = void 0; | ||
Object.defineProperty(exports, "logger", { | ||
@@ -111,8 +113,2 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "releaseChecker", { | ||
enumerable: true, | ||
get: function () { | ||
return _releaseChecker.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "resolveNodeModuleDir", { | ||
@@ -124,2 +120,3 @@ enumerable: true, | ||
}); | ||
exports.version = void 0; | ||
var _logger = _interopRequireDefault(require("./logger")); | ||
@@ -132,3 +129,4 @@ var _isPackagerRunning = _interopRequireDefault(require("./isPackagerRunning")); | ||
var _launchEditor = _interopRequireDefault(require("./launchEditor")); | ||
var _releaseChecker = _interopRequireDefault(require("./releaseChecker")); | ||
var _version = _interopRequireWildcard(require("./releaseChecker")); | ||
exports.version = _version; | ||
var _resolveNodeModuleDir = _interopRequireDefault(require("./resolveNodeModuleDir")); | ||
@@ -139,2 +137,4 @@ var _hookStdout = _interopRequireDefault(require("./hookStdout")); | ||
var _printRunDoctorTip = _interopRequireDefault(require("./printRunDoctorTip")); | ||
var _link = _interopRequireWildcard(require("./doclink")); | ||
exports.link = _link; | ||
var _errors = require("./errors"); | ||
@@ -152,4 +152,6 @@ Object.keys(_errors).forEach(function (key) { | ||
}); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
//# sourceMappingURL=index.js.map |
@@ -31,4 +31,4 @@ "use strict"; | ||
} catch (err) { | ||
if (err) { | ||
_logger.default.error('Browser exited with error:', err); | ||
if (err instanceof Error) { | ||
_logger.default.error('Browser exited with error:', err.message); | ||
} | ||
@@ -35,0 +35,0 @@ } |
import type { Ora, Options, Spinner, Color } from 'ora'; | ||
export declare type Loader = Ora; | ||
export type Loader = Ora; | ||
declare class OraNoop implements Loader { | ||
@@ -4,0 +4,0 @@ spinner: Spinner; |
@@ -1,2 +0,2 @@ | ||
export declare type Release = { | ||
export type Release = { | ||
version: string; | ||
@@ -13,3 +13,3 @@ changelogUrl: string; | ||
*/ | ||
export default function getLatestRelease(name: string, currentVersion: string): Promise<Release | void>; | ||
export default function getLatestRelease(name: string, currentVersion: string): Promise<Release | undefined>; | ||
//# sourceMappingURL=getLatestRelease.d.ts.map |
@@ -61,2 +61,3 @@ "use strict"; | ||
} | ||
return undefined; | ||
} | ||
@@ -63,0 +64,0 @@ function buildChangelogUrl(version) { |
@@ -1,2 +0,21 @@ | ||
export default function releaseChecker(root: string): Promise<void>; | ||
import { SemVer } from 'semver'; | ||
import { Release } from './getLatestRelease'; | ||
/** | ||
* Logs out a message if the user's version is behind a stable version of React Native | ||
*/ | ||
export declare function logIfUpdateAvailable(projectRoot: string): Promise<void>; | ||
type Update = { | ||
upgrade: Release; | ||
current: string; | ||
name: string; | ||
}; | ||
/** | ||
* Finds the latest stables version of React Native > current version | ||
*/ | ||
export declare function latest(projectRoot: string): Promise<Update | undefined>; | ||
/** | ||
* Gets the current project's version parsed as Semver | ||
*/ | ||
export declare function current(projectRoot: string): SemVer | undefined; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -6,3 +6,5 @@ "use strict"; | ||
}); | ||
exports.default = releaseChecker; | ||
exports.current = current; | ||
exports.latest = latest; | ||
exports.logIfUpdateAvailable = logIfUpdateAvailable; | ||
function _path() { | ||
@@ -15,2 +17,10 @@ const data = _interopRequireDefault(require("path")); | ||
} | ||
function _semver() { | ||
const data = _interopRequireDefault(require("semver")); | ||
_semver = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _errors = require("../errors"); | ||
var _logger = _interopRequireDefault(require("../logger")); | ||
@@ -21,15 +31,35 @@ var _resolveNodeModuleDir = _interopRequireDefault(require("../resolveNodeModuleDir")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// @ts-ignore - JS file | ||
const getReactNativeVersion = projectRoot => { | ||
var _require; | ||
return (_require = require(_path().default.join((0, _resolveNodeModuleDir.default)(projectRoot, 'react-native'), 'package.json'))) === null || _require === void 0 ? void 0 : _require.version; | ||
}; | ||
async function releaseChecker(root) { | ||
/** | ||
* Logs out a message if the user's version is behind a stable version of React Native | ||
*/ | ||
async function logIfUpdateAvailable(projectRoot) { | ||
const hasUpdate = await latest(projectRoot); | ||
if (hasUpdate) { | ||
(0, _printNewRelease.default)(hasUpdate.name, hasUpdate.upgrade, hasUpdate.current); | ||
} | ||
} | ||
/** | ||
* Finds the latest stables version of React Native > current version | ||
*/ | ||
async function latest(projectRoot) { | ||
try { | ||
const currentVersion = getReactNativeVersion(projectRoot); | ||
if (!currentVersion) { | ||
return; | ||
} | ||
const { | ||
version: currentVersion | ||
} = require(_path().default.join((0, _resolveNodeModuleDir.default)(root, 'react-native'), 'package.json')); | ||
const { | ||
name | ||
} = require(_path().default.join(root, 'package.json')); | ||
} = require(_path().default.join(projectRoot, 'package.json')); | ||
const latestRelease = await (0, _getLatestRelease.default)(name, currentVersion); | ||
if (latestRelease) { | ||
(0, _printNewRelease.default)(name, latestRelease, currentVersion); | ||
return { | ||
name, | ||
current: currentVersion, | ||
upgrade: latestRelease | ||
}; | ||
} | ||
@@ -42,4 +72,20 @@ } catch (e) { | ||
} | ||
return undefined; | ||
} | ||
/** | ||
* Gets the current project's version parsed as Semver | ||
*/ | ||
function current(projectRoot) { | ||
try { | ||
const found = _semver().default.parse(getReactNativeVersion(projectRoot)); | ||
if (found) { | ||
return found; | ||
} | ||
} catch (_) { | ||
throw new _errors.UnknownProjectError(projectRoot); | ||
} | ||
return undefined; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -14,4 +14,7 @@ "use strict"; | ||
} | ||
var link = _interopRequireWildcard(require("../doclink")); | ||
var _logger = _interopRequireDefault(require("../logger")); | ||
var _releaseCacheManager = _interopRequireDefault(require("./releaseCacheManager")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -25,3 +28,3 @@ /** | ||
_logger.default.info(`Diff: ${_chalk().default.dim.underline(latestRelease.diffUrl)}`); | ||
_logger.default.info(`For more info, check out "${_chalk().default.dim.underline('https://reactnative.dev/docs/upgrading')}".`); | ||
_logger.default.info(`For more info, check out "${_chalk().default.dim.underline(link.docs('upgrading'))}".`); | ||
_releaseCacheManager.default.set(name, 'lastChecked', new Date().toISOString()); | ||
@@ -28,0 +31,0 @@ } |
@@ -1,2 +0,2 @@ | ||
declare type ReleaseCacheKey = 'eTag' | 'lastChecked' | 'latestVersion'; | ||
type ReleaseCacheKey = 'eTag' | 'lastChecked' | 'latestVersion'; | ||
declare function get(name: string, key: ReleaseCacheKey): string | undefined; | ||
@@ -3,0 +3,0 @@ declare function set(name: string, key: ReleaseCacheKey, value: string): void; |
{ | ||
"name": "@react-native-community/cli-tools", | ||
"version": "11.0.0-alpha.2", | ||
"version": "11.0.0", | ||
"license": "MIT", | ||
@@ -21,6 +21,6 @@ "main": "build/index.js", | ||
"devDependencies": { | ||
"@react-native-community/cli-types": "^11.0.0-alpha.2", | ||
"@react-native-community/cli-types": "^11.0.0", | ||
"@types/lodash": "^4.14.149", | ||
"@types/mime": "^2.0.1", | ||
"@types/node": "^14.0.0", | ||
"@types/node": "^16.0.0", | ||
"@types/node-fetch": "^2.5.5", | ||
@@ -40,3 +40,3 @@ "@types/shell-quote": "^1.7.1" | ||
}, | ||
"gitHead": "63022103bebc9202d15255d8d2a6b90ce7401bf0" | ||
"gitHead": "e0c9bcea9cb7af9548052d80846bb45f187a28a3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
155441
86
1711
1