Skip to content

Commit

Permalink
feat: generate .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalovelo authored and thepiwo committed Jan 9, 2023
1 parent 53a2446 commit eecf555
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/init/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"artifactsDest": "./",
"artifactsDir": "/artifacts",
"updateArtifactsDir": "/update-artifacts",
"recommendedGitIgnore":"/recommended-gitignore.txt",
"dependencies": [
"@aeternity/aepp-sdk@12"
],
Expand Down
11 changes: 11 additions & 0 deletions src/init/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const createAEprojectProjectStructure = async (folder) => {

await setupArtifacts(folder);
await installDependencies(folder);
await generateGitIgnore(folder);

print('===== aeproject successfully initialized =====');
print('test/exampleTest.js and contract/ExampleContract.aes have been added as example how to use aeproject');
Expand Down Expand Up @@ -95,6 +96,16 @@ const updateArtifacts = async (folder) => {
await copyFolderRecursiveSync(fileSource, folder);
};

/**
* generates a .gitignore file based on the content of
* recommended-gitignore.txt
* @param {string} folder - folder to add .gitignore
*/
const generateGitIgnore = async (folder) => {
const gitIgnorePath = path.join(folder, '.gitignore');
await fs.promises.copyFile(`${__dirname}${constants.recommendedGitIgnore}`, gitIgnorePath);
};

module.exports = {
run,
};
2 changes: 2 additions & 0 deletions src/init/recommended-gitignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
build
5 changes: 5 additions & 0 deletions tests/happy-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const chai = require('chai');
const chaiFiles = require('chai-files');
const { isEnvRunning } = require('../src/env/env');
const { version } = require('../package.json');
const constants = require('../src/init/constants.json');

chai.use(chaiFiles);
const { assert } = chai;
Expand Down Expand Up @@ -40,6 +41,10 @@ describe('Happy Path', () => {
const res = await exec(folder ? `aeproject init ${folder}` : 'aeproject init', { cwd });
assert.equal(res.code, 0);

const generatedGitIgnore = file(path.join(cwd, '.gitignore')).content;
const expectedGitIgnore = file(path.join(__dirname, `../src/init/${constants.recommendedGitIgnore}`)).content;
assert.equal(generatedGitIgnore, expectedGitIgnore);

// link to use local aeproject utils
await exec('npm link @aeternity/aeproject', { cwd: folder ? path.join(cwd, folder) : cwd });

Expand Down

0 comments on commit eecf555

Please sign in to comment.