Skip to content

Commit

Permalink
chore: remove stale templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Aug 11, 2020
1 parent 054bad6 commit 7e037c5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 191 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
language: node_js
os:
- linux
- osx
node_js:
- 13
- 12
Expand Down
31 changes: 20 additions & 11 deletions src/commands/deploy/heroku.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import chalk from 'chalk';
import execa from 'execa';
import fs from 'fs';
import inquirer from 'inquirer';
import path from 'path';

import appData from '../../utils/projectConfig';
import { validateInput } from '../../utils/validate';
Expand Down Expand Up @@ -92,12 +93,12 @@ const deployToHeroku = async (templateDir) => {
const projectConfig = appData();
const { template } = projectConfig;

if (!fs.existsSync(`./${templateDir}/.git`)) {
if (!fs.existsSync(path.join(templateDir, '.git'))) {
await execa.shell('git init', { cwd: templateDir });
const fileContent = fs.existsSync('./server/.env')
const fileContent = fs.existsSync(path.join('server', '.env'))
? 'node_modules\n.env'
: 'node_modules';
fs.writeFileSync(`./${templateDir}/.gitignore`, fileContent);
fs.writeFileSync(path.join(templateDir, '.gitignore'), fileContent);
} else {
const { stdout } = await execa.shell('git status', { cwd: templateDir });
if (stdout.includes('nothing to commit')) {
Expand All @@ -117,7 +118,10 @@ const deployToHeroku = async (templateDir) => {
}

// It depends on a DBAAS
if (templateDir === 'server' && fs.existsSync('./server/models')) {
if (
templateDir === 'server' &&
fs.existsSync(path.join('server', 'models'))
) {
await setConfigVar('DB_URL', templateDir);
}

Expand All @@ -130,8 +134,9 @@ const deployToHeroku = async (templateDir) => {
await setConfigVar('NODE_ENV', templateDir, 'production');

// Create Procfile
if (!fs.existsSync('./client/Procfile')) {
fs.writeFileSync('./client/Procfile', 'web: nuxt start');
const procFilePath = path.join('client', 'Procfile');
if (!fs.existsSync(procFilePath)) {
fs.writeFileSync(procFilePath, 'web: nuxt start');
}
} else {
const staticConfig = {
Expand All @@ -142,9 +147,10 @@ const deployToHeroku = async (templateDir) => {
},
};

if (!fs.existsSync('./client/static.json')) {
const staticConfigPath = path.join('client', 'static.json');
if (!fs.existsSync(staticConfigPath)) {
fs.writeFileSync(
'./client/static.json',
staticConfigPath,
JSON.stringify(staticConfig, null, 2),
);
}
Expand All @@ -159,7 +165,9 @@ const deployToHeroku = async (templateDir) => {
'app.listen(port);',
];

let pkgJson = JSON.parse(fs.readFileSync('./client/package.json'));
let pkgJson = JSON.parse(
fs.readFileSync(path.join('client', 'package.json')),
);
const buildCmd = 'npm run build';
const postInstallScript = `if test \"$NODE_ENV\" = \"production\" ; then ${buildCmd} ; fi `; // eslint-disable-line
pkgJson = {
Expand All @@ -171,8 +179,9 @@ const deployToHeroku = async (templateDir) => {
},
};

if (!fs.existsSync('./client/server.js')) {
fs.writeFileSync('./client/server.js', starterSource.join('\n'));
const serverFilePath = path.join('client', 'server.js');
if (!fs.existsSync(serverFilePath)) {
fs.writeFileSync(serverFilePath, starterSource.join('\n'));
pkgJson.scripts['preinstall'] =
'npm install --save express serve-static';
fs.writeFileSync(
Expand Down
12 changes: 9 additions & 3 deletions src/commands/deploy/surge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import execa from 'execa';
import fs from 'fs';
import path from 'path';

import appData from '../../utils/projectConfig';
import exec from '../../utils/exec';
Expand All @@ -16,10 +17,11 @@ const deployToSurge = async () => {
await validateInstallation('surge --help');
console.log();

const { template } = appData();
const projectConfig = appData();
const { template, isConfigured } = projectConfig;
const cmd = template === 'Nuxt.js' ? 'generate' : 'build';

if (!fs.existsSync('./client/node_modules')) {
if (!isConfigured.client) {
await exec(
`npm install`,
'Installing dependencies',
Expand All @@ -28,6 +30,10 @@ const deployToSurge = async () => {
cwd: 'client',
},
);

// Update .mevnrc
projectConfig.isConfigured.client = true;
fs.writeFileSync('.mevnrc', JSON.stringify(projectConfig, null, 2));
}

// Create a production build with npm run build
Expand All @@ -36,7 +42,7 @@ const deployToSurge = async () => {
});

// Fire up the surge CLI
await execa('surge', { cwd: 'client/dist', stdio: 'inherit' });
await execa('surge', { cwd: path.join('client', 'dist'), stdio: 'inherit' });
};

module.exports = deployToSurge;
36 changes: 0 additions & 36 deletions src/templates/routes/FacebookRoutes.js

This file was deleted.

39 changes: 0 additions & 39 deletions src/templates/routes/GoogleRoutes.js

This file was deleted.

36 changes: 0 additions & 36 deletions src/templates/routes/TwitterRoutes.js

This file was deleted.

25 changes: 0 additions & 25 deletions src/templates/routes/index_with_passport.js

This file was deleted.

41 changes: 0 additions & 41 deletions src/templates/routes/index_with_social_media_auth.js

This file was deleted.

0 comments on commit 7e037c5

Please sign in to comment.