-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Installation script crash (#66)
## Description This PR: - fixes incorrect commands in readme, - updates husky setup (was deprecated), - is an attempt to fix `npx rn-lib-temp` command run (hope it will work)
- Loading branch information
Showing
12 changed files
with
130 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,5 @@ template/js | |
!.yarn/releases | ||
!.yarn/plugins | ||
.pnp.* | ||
|
||
*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
PACKAGE_JSON="package.json" | ||
PACKAGE_JSON_BAK="package.json.bak" | ||
|
||
# Check if package.json exists | ||
if [ ! -f "$PACKAGE_JSON" ]; then | ||
echo "Error: $PACKAGE_JSON not found." | ||
exit 1 | ||
fi | ||
|
||
# Backup the original package.json | ||
cp "$PACKAGE_JSON" "$PACKAGE_JSON_BAK" | ||
|
||
# Execute the Node.js script to modify package.json | ||
node ./scripts/remove-scripts.js | ||
|
||
# Check if the Node.js script executed successfully | ||
if [ $? -ne 0 ]; then | ||
echo "Error: Failed to modify package.json." | ||
# Restore the original package.json before exiting | ||
mv "$PACKAGE_JSON_BAK" "$PACKAGE_JSON" | ||
exit 1 | ||
fi | ||
|
||
# Run npm pack | ||
npm pack | ||
|
||
# Capture the exit status of npm pack | ||
PACK_STATUS=$? | ||
|
||
# Restore the original package.json | ||
mv "$PACKAGE_JSON_BAK" "$PACKAGE_JSON" | ||
|
||
# Check if npm pack was successful | ||
if [ $PACK_STATUS -ne 0 ]; then | ||
echo "Error: npm pack failed." | ||
exit 1 | ||
fi | ||
|
||
echo "Successfully packed the package and restored the original package.json." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env node | ||
|
||
import fs from 'fs'; | ||
import chalk from 'chalk'; | ||
|
||
const PACKAGE_JSON = 'package.json'; | ||
|
||
let packageJson; | ||
try { | ||
packageJson = JSON.parse(fs.readFileSync(PACKAGE_JSON, 'utf8')); | ||
} catch (error) { | ||
console.error(chalk.red('Error reading package.json:'), error); | ||
process.exit(1); | ||
} | ||
|
||
// Remove the postinstall and prepare scripts if they exist | ||
if (packageJson.scripts) { | ||
const scriptsRemoved = []; | ||
if (packageJson.scripts.postinstall) { | ||
delete packageJson.scripts.postinstall; | ||
scriptsRemoved.push('postinstall'); | ||
} | ||
if (packageJson.scripts.prepare) { | ||
delete packageJson.scripts.prepare; | ||
scriptsRemoved.push('prepare'); | ||
} | ||
if (scriptsRemoved.length > 0) { | ||
console.log( | ||
chalk.green('Removed scripts: ') + chalk.yellow(scriptsRemoved.join(', ')) | ||
); | ||
} else { | ||
console.log(chalk.blue('No scripts to remove.')); | ||
} | ||
} else { | ||
console.log(chalk.blue('No scripts section found in package.json.')); | ||
} | ||
|
||
try { | ||
fs.writeFileSync(PACKAGE_JSON, JSON.stringify(packageJson, null, 2)); | ||
} catch (error) { | ||
console.error(chalk.red('Error writing package.json:'), error); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
if [ -d '.git' ]; then | ||
npx husky install | ||
npx husky init | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters