Skip to content

Commit

Permalink
fix: npm package creation issues and make it lighter (#67)
Browse files Browse the repository at this point in the history
## Description

This PR removes unnecessarily included files in the npm package. It adds
checks to `prepare` and `postinstall` commands to ensue they executed
only if possible (they are used in development only).
  • Loading branch information
MatiPl01 authored Nov 16, 2024
1 parent e56f906 commit 3ec339a
Show file tree
Hide file tree
Showing 10 changed files with 4,439 additions and 6,826 deletions.
6 changes: 0 additions & 6 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@
"changelogFile": "CHANGELOG.md"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "./scripts/create-npm-package.sh"
}
],
"@semantic-release/npm",
[
"@semantic-release/git",
Expand Down
934 changes: 0 additions & 934 deletions .yarn/releases/yarn-4.5.1.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions .yarnrc.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Before starting development, go to the directory where you created the template
yarn
```

**For iOS only**: Install required Pods for the bare React Native example app (`examples/fabric` or `examples/paper`):
**For iOS only**: Install required Pods for the bare React Native example app (`example/fabric` or `example/paper`):

```sh
yarn pod
Expand Down
4 changes: 2 additions & 2 deletions bin/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ const init = (projectName, verbose = false, directory = '.') => {

logger.info('\n\n💻 Useful commands:');
logger.info('1. Bare React Native example app:');
logger.info(' - cd examples/fabric or cd examples/paper');
logger.info(' - cd example/fabric or cd example/paper');
logger.info(' - yarn pod - install pods for iOS');
logger.info(' - yarn start - start the Metro bundler');
logger.info(' - yarn android - run the Android app');
logger.info(' - yarn ios - run the iOS app');

logger.info('\n2. Expo example app:');
logger.info(' - cd examples/expo');
logger.info(' - cd example/expo');
logger.info(' - yarn start - start the Expo Go app');
logger.info(' - yarn android - run the Android app');
logger.info(' - yarn ios - run the iOS app');
Expand Down
25 changes: 19 additions & 6 deletions bin/rename.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,29 @@ const renameExpoApp = (projectPath, projectName, verbose) => {
}
};

const renameBareApp = (projectPath, projectName, verbose) => {
const iosPath = path.resolve(projectPath, 'example', 'bare', 'ios');
const androidPath = path.resolve(projectPath, 'example', 'bare', 'android');
const appJsonPath = path.resolve(projectPath, 'example', 'bare', 'app.json');
const renameBareApp = (projectPath, projectName, exampleName, verbose) => {
const iosPath = path.resolve(projectPath, 'example', exampleName, 'ios');
const androidPath = path.resolve(
projectPath,
'example',
exampleName,
'android'
);
const appJsonPath = path.resolve(
projectPath,
'example',
exampleName,
'app.json'
);
const replacements = [
[LIB_KEBAB_CASE_NAME, projectName],
[LIB_CAMEL_CASE_NAME, toCamelCase(projectName)]
];

if (verbose) {
logger.info(`Updating app.json in bare project at ${appJsonPath}`);
logger.info(
`Updating app.json in ${exampleName} project at ${appJsonPath}`
);
}

replacePlaceholdersInFile(appJsonPath, replacements, verbose);
Expand All @@ -190,6 +202,7 @@ export default (projectPath, projectName, verbose) => {
renamePlaceholdersInExampleApp(projectPath, projectName, verbose);
renamePlaceholdersInGithubWorkflows(projectPath, projectName, verbose);
renameExpoApp(projectPath, projectName, verbose);
renameBareApp(projectPath, projectName, verbose);
renameBareApp(projectPath, projectName, 'fabric', verbose);
renameBareApp(projectPath, projectName, 'paper', verbose);
logger.success('All renaming steps completed successfully.');
};
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"@eslint/js": "^9.1.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^13.0.0",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^10.0.7",
"@semantic-release/npm": "^12.0.1",
Expand All @@ -31,8 +30,6 @@
},
"files": [
"LICENSE",
"scripts",
"template",
"bin"
],
"homepage": "https://github.com/MatiPl01/react-native-library-template#readme",
Expand Down Expand Up @@ -63,7 +60,6 @@
"yarn format:deps"
]
},
"packageManager": "yarn@4.5.1",
"publishConfig": {
"access": "public"
},
Expand All @@ -83,8 +79,8 @@
"library:install": "cd template && yarn && cd ..",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"postinstall": "yarn library:install",
"prepare": "husky"
"postinstall": "(yarn library:install || :) >/dev/null 2>&1",
"prepare": "(husky install || :) >/dev/null 2>&1"
},
"type": "module"
}
41 changes: 0 additions & 41 deletions scripts/create-npm-package.sh

This file was deleted.

43 changes: 0 additions & 43 deletions scripts/remove-scripts.js

This file was deleted.

Loading

0 comments on commit 3ec339a

Please sign in to comment.