Skip to content

Commit 28d75b2

Browse files
committed
fix(template): ensure gitignore is available during template stage
Also update template dependencies. release-npm
1 parent a97279f commit 28d75b2

File tree

3 files changed

+35
-30
lines changed

3 files changed

+35
-30
lines changed

customize.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { join } from 'path'
2-
import { readFileSync, writeFileSync } from 'fs'
2+
import { existsSync, readFileSync, writeFileSync } from 'fs'
33

44
const files = [
55
'app/App.js',
@@ -19,6 +19,11 @@ const files = [
1919
export default (name, directory) => {
2020
const replaceTemplateVariables = (file) => {
2121
const filePath = join(directory, file)
22+
23+
if (!existsSync(filePath)) {
24+
return
25+
}
26+
2227
let contents = readFileSync(filePath, 'utf-8')
2328

2429
contents = contents.replace(/<%= name %>/g, name.regular)

index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ const destinationDirectory = join(process.cwd(), name.regular)
3636

3737
cpSync(templateDirectory, destinationDirectory, { recursive: true })
3838

39+
const npmIgnorePath = join(destinationDirectory, '.npmignore')
40+
41+
if (existsSync(npmIgnorePath)) {
42+
// npm will apparently rename .gitignore outside a repo to prevent accidentially publishing.
43+
// Since this template specifies "files" in package.json that doesn't happen.
44+
renameSync(npmIgnorePath, join(destinationDirectory, '.gitignore'))
45+
}
46+
3947
customize(name, destinationDirectory)
4048

4149
console.log('Installing dependencies...')
@@ -45,14 +53,6 @@ execSync('npm install --legacy-peer-deps', {
4553
stdio: 'inherit',
4654
})
4755

48-
const npmIgnorePath = join(destinationDirectory, '.npmignore')
49-
50-
if (existsSync(npmIgnorePath)) {
51-
// npm will apparently rename .gitignore outside a repo to prevent accidentially publishing.
52-
// Since this template specifies "files" in package.json that doesn't happen.
53-
renameSync(npmIgnorePath, join(destinationDirectory, '.gitignore'))
54-
}
55-
5656
console.log('')
5757
console.log(`😃 Created new plugin called ${name.regular} in ${destinationDirectory}.`)
5858
console.log(`🛠️ Start coding in the file ./index.tsx.`)

template/package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,34 @@
2222
"format": "prettier \"{,!(app|dist)/**/}*.{ts,tsx}\" --write"
2323
},
2424
"peerDependencies": {
25-
"react": "^18.1.0",
26-
"react-native": "^0.68.2"
25+
"react": "^18.2.0",
26+
"react-native": "^0.69.1"
2727
},
2828
"devDependencies": {
29-
"@babel/core": "^7.17.12",
30-
"@babel/runtime": "^7.17.9",
31-
"@react-native-community/eslint-config": "3.0.2",
32-
"@types/jest": "^27.5.1",
33-
"@types/react": "^18.0.9",
34-
"@types/react-native": "^0.67.7",
29+
"@babel/core": "^7.18.6",
30+
"@babel/runtime": "^7.18.6",
31+
"@react-native-community/eslint-config": "3.0.3",
32+
"@types/jest": "^28.1.4",
33+
"@types/react": "^18.0.15",
34+
"@types/react-native": "^0.69.2",
3535
"@types/react-test-renderer": "^18.0.0",
36-
"@typescript-eslint/eslint-plugin": "^5.25.0",
37-
"@typescript-eslint/parser": "^5.25.0",
38-
"babel-jest": "^28.1.0",
39-
"concurrently": "^7.2.0",
36+
"@typescript-eslint/eslint-plugin": "^5.30.5",
37+
"@typescript-eslint/parser": "^5.30.5",
38+
"babel-jest": "^28.1.2",
39+
"concurrently": "^7.2.2",
4040
"cpx": "^1.5.0",
41-
"esbuild": "^0.14.39",
42-
"eslint": "^8.15.0",
41+
"esbuild": "^0.14.48",
42+
"eslint": "^8.19.0",
4343
"eslint-plugin-flowtype": "^8.0.3",
44-
"jest": "^27.5.1",
45-
"metro-react-native-babel-preset": "^0.70.3",
46-
"prettier": "^2.6.2",
47-
"react": "^18.1.0",
48-
"react-native": "^0.68.2",
49-
"react-test-renderer": "^18.1.0",
44+
"jest": "^28.1.2",
45+
"metro-react-native-babel-preset": "^0.71.2",
46+
"prettier": "^2.7.1",
47+
"react": "^18.2.0",
48+
"react-native": "^0.69.1",
49+
"react-test-renderer": "^18.2.0",
5050
"recursive-copy": "^2.0.14",
5151
"rimraf": "^3.0.2",
52-
"typescript": "^4.6.4"
52+
"typescript": "^4.7.4"
5353
},
5454
"files": [
5555
"dist"

0 commit comments

Comments
 (0)