mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-09-16 09:41:38 +08:00
check lockfile
This commit is contained in:
@@ -13,6 +13,8 @@ const properties = require('properties');
|
|||||||
import { depVersions } from './utils/dep-versions';
|
import { depVersions } from './utils/dep-versions';
|
||||||
import { t } from './utils/i18n';
|
import { t } from './utils/i18n';
|
||||||
import { tempDir } from './utils/constants';
|
import { tempDir } from './utils/constants';
|
||||||
|
import { checkLockFiles } from './utils/check-lockfile';
|
||||||
|
import { addGitIgnore } from './utils/add-gitignore';
|
||||||
|
|
||||||
let bsdiff;
|
let bsdiff;
|
||||||
let hdiff;
|
let hdiff;
|
||||||
@@ -913,6 +915,9 @@ export const commands = {
|
|||||||
platform,
|
platform,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
checkLockFiles();
|
||||||
|
addGitIgnore();
|
||||||
|
|
||||||
const bundleParams = await checkPlugins();
|
const bundleParams = await checkPlugins();
|
||||||
const sourcemapPlugin = bundleParams.sourcemap;
|
const sourcemapPlugin = bundleParams.sourcemap;
|
||||||
const isSentry = bundleParams.sentry;
|
const isSentry = bundleParams.sentry;
|
||||||
|
@@ -5,7 +5,6 @@ import updateNotifier from 'update-notifier';
|
|||||||
import { printVersionCommand } from './utils';
|
import { printVersionCommand } from './utils';
|
||||||
import pkg from '../package.json';
|
import pkg from '../package.json';
|
||||||
import { t } from './utils/i18n';
|
import { t } from './utils/i18n';
|
||||||
import { addGitIgnore } from './utils/add-gitignore';
|
|
||||||
|
|
||||||
updateNotifier({ pkg }).notify({
|
updateNotifier({ pkg }).notify({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
@@ -33,7 +32,6 @@ const commands = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
addGitIgnore();
|
|
||||||
await printVersionCommand();
|
await printVersionCommand();
|
||||||
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
if (process.argv.indexOf('-v') >= 0 || process.argv[2] === 'version') {
|
||||||
process.exit();
|
process.exit();
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import path from 'node:path';
|
// import path from 'node:path';
|
||||||
import { credentialFile, tempDir } from './constants';
|
import { credentialFile, tempDir } from './constants';
|
||||||
|
|
||||||
export function addGitIgnore() {
|
export function addGitIgnore() {
|
||||||
const shouldIgnore = [credentialFile, tempDir];
|
const shouldIgnore = [credentialFile, tempDir];
|
||||||
|
|
||||||
const gitignorePath = path.join(process.cwd(), '.gitignore');
|
const gitignorePath = '.gitignore';
|
||||||
|
|
||||||
if (!fs.existsSync(gitignorePath)) {
|
if (!fs.existsSync(gitignorePath)) {
|
||||||
return;
|
return;
|
||||||
@@ -16,7 +16,7 @@ export function addGitIgnore() {
|
|||||||
const gitignoreLines = gitignoreContent.split('\n');
|
const gitignoreLines = gitignoreContent.split('\n');
|
||||||
|
|
||||||
for (const line of gitignoreLines) {
|
for (const line of gitignoreLines) {
|
||||||
const index = shouldIgnore.indexOf(line);
|
const index = shouldIgnore.indexOf(line.trim());
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
shouldIgnore.splice(index, 1);
|
shouldIgnore.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
24
src/utils/check-lockfile.ts
Normal file
24
src/utils/check-lockfile.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import fs from 'node:fs';
|
||||||
|
import { t } from '../../lib/utils/i18n';
|
||||||
|
|
||||||
|
const lockFiles = [
|
||||||
|
'package-lock.json',
|
||||||
|
'yarn.lock',
|
||||||
|
'pnpm-lock.yaml',
|
||||||
|
'bun.lockb',
|
||||||
|
'bun.lock',
|
||||||
|
];
|
||||||
|
|
||||||
|
const existingLockFiles: string[] = [];
|
||||||
|
export function checkLockFiles() {
|
||||||
|
for (const file of lockFiles) {
|
||||||
|
if (fs.existsSync(file)) {
|
||||||
|
existingLockFiles.push(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (existingLockFiles.length === 0) {
|
||||||
|
console.warn(t('lockFilesNotFound'));
|
||||||
|
} else if (existingLockFiles.length > 1) {
|
||||||
|
console.warn(t('multipleLockFilesFound'));
|
||||||
|
}
|
||||||
|
}
|
@@ -1,7 +0,0 @@
|
|||||||
const lockFiles = [
|
|
||||||
'package-lock.json',
|
|
||||||
'yarn.lock',
|
|
||||||
'pnpm-lock.yaml',
|
|
||||||
'bun.lockb',
|
|
||||||
'bun.lock',
|
|
||||||
];
|
|
Reference in New Issue
Block a user