Skip to content

Commit 52e4ecc

Browse files
Fixing .gitignores
`yarn pack` doesn't add `.gitignore` files to the package, so they don't end up in the spawned repos. Using `gitignore` (without dot) files instead, and renaming them in spawning script
1 parent 759b021 commit 52e4ecc

File tree

6 files changed

+8
-2
lines changed

6 files changed

+8
-2
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ npx --yes --package=<path-to-create-polkadot-dapp>/dist create-polkadot-dapp
3535

3636
### Adding new template
3737
Add sources to `templates/` directory. These will be copied to target directory.
38-
Add new configuration to `src/templateConfigs/` and export it from `index.ts`. The exported name must match the directory name in `templates/`.
38+
Add new configuration to `src/templateConfigs/` and export it from `index.ts`. The exported name must match the directory name in `templates/`.
39+
40+
#### Note on `.gitignore`
41+
`yarn pack` doesn't include `.gitignore` files into the package, even if manually included into `files` section in package.json.
42+
To circumvent this, we're placing `gitignore` (without the dot) files in the templates instead, and renaming the files after spawning.
3943

4044
### Back sync
4145
It can be more convenient to develop template code outside of `create-polkadot-dapp`.

src/scripts/backSync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ program
2020
program.parse();
2121
const options: { source: string; template: TemplateNames; rm: boolean } = program.opts();
2222

23-
const alwaysIgnorePatterns = [/^\.papi\/metadata.*/];
23+
const alwaysIgnorePatterns = [/^\.papi\/metadata.*/, /^\.gitignore$/];
2424

2525
const gitignoreContents = fs.readFileSync(path.join(options.source, ".gitignore"), "utf-8");
2626
const gitignoreIg = ignore().add(gitignoreContents);

src/util/spawnTemplate.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ async function updateFiles(dappData: DappData, targetDir: string): Promise<void>
5454

5555
await fs.writeFile(pkgJsonPath, JSON.stringify(pkgJsonContent, null, 2));
5656
}
57+
58+
await fs.rename(path.join(targetDir, "gitignore"), path.join(targetDir, ".gitignore"));
5759
}
5860

5961
async function installDeps(targetDir: string, dappData: DappData): Promise<void> {
File renamed without changes.

0 commit comments

Comments
 (0)