From ba0c25875d40a80b7e24b8ba2ff93c606ff5d384 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 30 May 2018 17:51:31 -0400 Subject: [PATCH] XXX UPDATE WIP: CB-12397 fix .gitignore for plugins & platforms XXX TODO: USE fs-extra function instead, XXX WAITING FOR apache/cordova-create#14 to be merged NOTE: This implementation is a workaround for the npm .gitignore/.npmignore behavior discussed in: - npm/npm#1862 - npm/npm#3763 - npm/npm#7252 --- index.js | 21 +++++++++++++++++++++ spec/create.spec.js | 8 ++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 61181cab..05ba2f09 100644 --- a/index.js +++ b/index.js @@ -213,6 +213,17 @@ module.exports = function (dir, optionalId, optionalName, cfg, extEvents) { fs.mkdirSync(dir); } + // CB-12397 add .gitignore for plugins & platforms + // to generated app + // (use stock .npmignore for ignore file) + // NOTE: This is a workaround solution for the existing + // npm .gitignore/.npmignore behavior discussed in: + // npm/npm#1862 + // npm/npm#3763 + // npm/npm#7252 + const ignoreStockPath = + path.join(require('cordova-app-hello-world').dirname, '.npmignore'); + try { // Copy files from template to project if (cfg.lib.www.template) { @@ -263,6 +274,16 @@ module.exports = function (dir, optionalId, optionalName, cfg, extEvents) { pkgjson.version = DEFAULT_VERSION; fs.writeFileSync(pkgjsonPath, JSON.stringify(pkgjson, null, 4), 'utf8'); + + // XXX TODO USE fs-extra function instead, + // XXX WAITING FOR apache/cordova-create#14 to be merged + // CB-12397 add .gitignore for plugins & platforms + // to generated app + // XXX GONE: + shell.cp(ignoreStockPath, path.join(dir, '.gitignore')); + /* ** XXX TODO: + fs.copySync(ignoreStockPath, path.join(dir, '.gitignore')); + // */ } // Create basic project structure. diff --git a/spec/create.spec.js b/spec/create.spec.js index 022601c1..50aed3b7 100644 --- a/spec/create.spec.js +++ b/spec/create.spec.js @@ -146,8 +146,8 @@ describe('create end-to-end', function () { // Check if package.json exists. expect(path.join(project, 'package.json')).toExist(); - // [CB-12397] Check that .gitignore does not exist - expect(path.join(project, '.gitignore')).not.toExist(); + // [CB-12397] Check that .gitignore exists + expect(path.join(project, '.gitignore')).toExist(); // [CB-12397] Check that .npmignore exists expect(path.join(project, '.npmignore')).toExist(); @@ -164,8 +164,8 @@ describe('create end-to-end', function () { expect(path.join(project, 'www', 'js')).not.toExist(); expect(path.join(project, 'www', 'js', 'index.js')).not.toExist(); - // [CB-12397] Check that .gitignore does not exist - expect(path.join(project, '.gitignore')).not.toExist(); + // [CB-12397] Check that .gitignore exists + expect(path.join(project, '.gitignore')).toExist(); // [CB-12397] Check that .npmignore does not exist expect(path.join(project, '.npmignore')).not.toExist();