Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-apollo-app

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-apollo-app - npm Package Compare versions

Comparing version 0.0.33 to 0.0.34

185

lib/index.js
"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
return t;
};
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
var creator_1 = require("@jsapp/creator");
var fs = require("fs");
var os = require("os");
var path = require("path");
var generator_1 = require("@larix/generator");
var chalk_1 = require("chalk");
require("source-map-support/register");

@@ -25,129 +51,16 @@ var templates_1 = require("./templates");

});
var writeWsGitignore = function (files, writeFile) {
var relPath = '.gitignore';
var dirRootSet = files[relPath];
if (dirRootSet && dirRootSet.length > 1 && dirRootSet[0].dstRoot === '.') {
var lineToBlock = {};
var blocks = [];
for (var _i = 0, dirRootSet_1 = dirRootSet; _i < dirRootSet_1.length; _i++) {
var dirRoots = dirRootSet_1[_i];
var text = fs.readFileSync(path.join(dirRoots.srcRoot, relPath), 'utf8');
var textLines = text.split(/\r\n|\r|\n/);
var curBlock = void 0;
for (var _a = 0, textLines_1 = textLines; _a < textLines_1.length; _a++) {
var line = textLines_1[_a];
if (line === '') {
curBlock = undefined;
}
else {
var block = lineToBlock[line];
if (block) {
curBlock = block;
}
else if (curBlock) {
curBlock.push(line);
lineToBlock[line] = curBlock;
}
else {
curBlock = [line];
lineToBlock[line] = curBlock;
blocks.push(curBlock);
}
}
}
(function () { return __awaiter(_this, void 0, void 0, function () {
var appName;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, generator_1.default(templates_1.default, generator_1.templateWriter, 'yarn create apollo-app', process.argv)];
case 1:
appName = (_a.sent()).appName;
console.log("App " + chalk_1.default.green(appName) + " generated successfully! Execute commands below to start it:\n");
console.log(chalk_1.default.yellow("cd " + appName));
console.log(chalk_1.default.yellow("yarn start"));
return [2];
}
writeFile(relPath, blocks.map(function (block) { return block.join(os.EOL); }).join(os.EOL + os.EOL));
}
};
var sortObject = function (obj) {
return Object.keys(obj)
.sort()
.reduce(function (result, key) {
result[key] = obj[key];
return result;
}, {});
};
var writeWsPkgJson = function (files, writeFile) {
var relPath = 'package.json';
var dirRootSet = files[relPath];
if (dirRootSet.length > 1 && dirRootSet[0].dstRoot === '.') {
var wsPkg = JSON.parse(fs.readFileSync(path.join(dirRootSet[0].srcRoot, relPath), 'utf8'));
for (var _i = 0, dirRootSet_2 = dirRootSet; _i < dirRootSet_2.length; _i++) {
var dirRoots = dirRootSet_2[_i];
var pkg = JSON.parse(creator_1.mergePkgJson(path.join(dirRoots.srcRoot, relPath), __dirname + '/../templates/presets/'));
pkg.name += '-' + path.basename(dirRoots.srcRoot);
for (var _a = 0, _b = ['devDependencies', 'resolutions']; _a < _b.length; _a++) {
var section = _b[_a];
if (pkg[section]) {
wsPkg[section] = __assign({}, (wsPkg[section] || {}), pkg[section]);
delete pkg[section];
}
}
writeFile(path.join(dirRoots.dstRoot, relPath), JSON.stringify(pkg, null, 2));
}
for (var _c = 0, _d = ['devDependencies', 'resolutions']; _c < _d.length; _c++) {
var section = _d[_c];
if (wsPkg[section]) {
wsPkg[section] = sortObject(wsPkg[section]);
}
}
writeFile(relPath, JSON.stringify(wsPkg, null, 2));
}
else {
var pkg = JSON.parse(creator_1.mergePkgJson(path.join(dirRootSet[0].srcRoot, relPath), __dirname + '/../templates/presets/'));
writeFile(relPath, JSON.stringify(pkg, null, 2));
}
};
var writeTsJson = function (relPath, files, writeFile) {
var dirRootSet = files[relPath];
if (dirRootSet && dirRootSet.length > 0) {
var wsConfig = JSON.parse(fs.readFileSync(path.join(dirRootSet[0].srcRoot, relPath), 'utf8'));
writeFile(path.join(dirRootSet[0].dstRoot, relPath), JSON.stringify(wsConfig, null, 2));
for (var _i = 0, _a = dirRootSet.slice(1); _i < _a.length; _i++) {
var dirRoots = _a[_i];
var config = JSON.parse(fs.readFileSync(path.join(dirRoots.srcRoot, relPath), 'utf8'));
var result = { extends: '../../' + relPath };
for (var _b = 0, _c = Object.keys(config); _b < _c.length; _b++) {
var key = _c[_b];
if (JSON.stringify(wsConfig[key]) !== JSON.stringify(config[key])) {
if (wsConfig[key]) {
for (var _d = 0, _e = Object.keys(config[key]); _d < _e.length; _d++) {
var option = _e[_d];
var wsValue = wsConfig[key][option];
var value = config[key][option];
if (JSON.stringify(value) !== JSON.stringify(wsValue)) {
result[key] = result[key] || {};
result[key][option] = config[key][option];
}
}
}
else {
result[key] = config[key];
}
}
}
writeFile(path.join(dirRoots.dstRoot, relPath), JSON.stringify(result, null, 2));
}
}
};
var templateWriter = function (files, writeFile) {
var isWorkspace = files['package.json'].length > 1 && files['package.json'][0].dstRoot === '.';
writeWsGitignore(files, writeFile);
writeWsPkgJson(files, writeFile);
writeTsJson('tsconfig.json', files, writeFile);
writeTsJson('tslint.json', files, writeFile);
for (var _i = 0, _a = Object.keys(files); _i < _a.length; _i++) {
var relPath = _a[_i];
if (['.gitignore', 'package.json', 'tsconfig.json', 'tslint.json'].indexOf(relPath) < 0) {
for (var _b = 0, _c = files[relPath]; _b < _c.length; _b++) {
var dirRoots = _c[_b];
var contents = path.basename(relPath) === 'package.json'
? creator_1.mergePkgJson(path.join(dirRoots.srcRoot, relPath), __dirname + '/../templates/presets/')
: fs.readFileSync(path.join(dirRoots.srcRoot, relPath), 'utf8');
writeFile(path.join(dirRoots.dstRoot, relPath), contents, { isWorkspace: isWorkspace });
}
}
}
};
creator_1.default(templates_1.default, templateWriter, 'yarn create apollo-app', process.argv);
});
}); })();
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

import { Template } from '@jsapp/creator';
import { Template } from '@larix/generator';
declare const templates: Template[];
export default templates;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var creator_1 = require("@jsapp/creator");
var generator_1 = require("@larix/generator");
var getWorkspaceRelFiles = function (packages) {
return creator_1.getTemplateFilePaths([{ srcRoot: __dirname + '/../templates/workspace', dstRoot: '.' }].concat(packages.map(function (name) { return ({
return generator_1.getTemplateFilePaths([{ srcRoot: __dirname + '/../templates/workspace', dstRoot: '.' }].concat(packages.map(function (name) { return ({
srcRoot: __dirname + '/../templates/' + name,

@@ -25,11 +25,11 @@ dstRoot: 'packages/' + name

title: '@server: TypeScript, Apollo (GraphQL), Express server',
files: creator_1.getTemplateFilePaths(__dirname + '/../templates/server')
files: generator_1.getTemplateFilePaths(__dirname + '/../templates/server')
},
{
title: '@web: TypeScript, Apollo (GraphQL), React web app',
files: creator_1.getTemplateFilePaths(__dirname + '/../templates/web')
files: generator_1.getTemplateFilePaths(__dirname + '/../templates/web')
},
{
title: '@mobile: TypeScript, Apollo (GraphQL), React Native for mobile',
files: creator_1.getTemplateFilePaths(__dirname + '/../templates/mobile')
files: generator_1.getTemplateFilePaths(__dirname + '/../templates/mobile')
}

@@ -36,0 +36,0 @@ ];

{
"name": "create-apollo-app",
"version": "0.0.33",
"version": "0.0.34",
"description": "Apollo GraphQL apps creator",

@@ -62,5 +62,6 @@ "author": "Victor Vlasenko <victor.vlasenko@sysgears.com>",

"dependencies": {
"@jsapp/creator": ">= 0.0.9",
"@larix/generator": ">=0.1.4",
"chalk": "^2.4.2",
"source-map-support": "^0.5.6"
}
}

@@ -7,7 +7,6 @@ {

"scripts": {
"start": "spin start",
"android": "spin -d web -d ios -e android start",
"ios": "spin -d web -d ios -e android start",
"build": "spin build",
"test": "spin test"
"start": "zen start",
"android": "zen -d web -d ios -e android start",
"ios": "zen -d web -d ios -e android start",
"build": "zen build"
},

@@ -14,0 +13,0 @@ "dependencies": {

{
"dependencies": {
"graphql-tools": "4.0.4"
},
"devDependencies": {

@@ -6,0 +3,0 @@ "dotenv": "^6.2.0",

{
"devDependencies": {
"@larix/zen": "0.1.8",
"@types/webpack-env": "1.13.7",

@@ -7,3 +8,2 @@ "cache-loader": "2.0.1",

"prettier": "1.16.4",
"spinjs": "0.4.192",
"uglifyjs-webpack-plugin": "^1.3.0",

@@ -10,0 +10,0 @@ "webpack": "4.29.5",

@@ -7,5 +7,4 @@ {

"scripts": {
"start": "spin start",
"build": "spin build",
"test": "spin test"
"start": "zen start",
"build": "zen build"
},

@@ -18,2 +17,3 @@ "dependencies": {

"express": "^4.16.4",
"graphql-tools": "4.0.4",
"opn": "^5.3.0",

@@ -25,4 +25,5 @@ "subscriptions-transport-ws": "^0.9.15"

"@types/express": "^4.11.1",
"@types/opn": "5.1.0",
"@types/ws": "^5.1.1"
}
}
import { Server } from 'http';
{;^isWorkspace;}
import * as opn from 'opn';
import opn from 'opn';
{;/isWorkspace;}

@@ -19,16 +19,24 @@

}
data.reloaded = true;
data.hotReloaded = true;
});
module.hot.addStatusHandler(status => {
if (status === 'fail') {
process.exit(250);
}
});
}
const firstStartInDevMode =
module.hot && process.env.LAST_EXIT_CODE === '0' && (!module.hot.data || !module.hot.data.hotReloaded);
startServer(PORT).then(serverInstance => {
if (!module.hot || !module.hot.data) {
if (!module.hot || firstStartInDevMode) {
console.log(`GraphQL Server is now running on http://localhost:${PORT}`);
{;^isWorkspace;}
if (module.hot) {
opn(`http://localhost:${PORT}/graphiql`);
if (firstStartInDevMode) {
opn(`http://localhost:${PORT}/api/swagger`);
}
{;/isWorkspace;}
}
server = serverInstance;

@@ -38,2 +46,3 @@ });

console.error(e);
process.exit(1);
}

@@ -7,5 +7,4 @@ {

"scripts": {
"start": "spin start",
"build": "spin build",
"test": "spin test"
"start": "zen start",
"build": "zen build"
},

@@ -12,0 +11,0 @@ "dependencies": {

@@ -5,7 +5,6 @@ {

"scripts": {
"start": "spin start -d android -d ios",
"android": "spin start -e android -d ios -d web",
"ios": "spin start -e ios -d android -d web",
"build": "spin build",
"test": "spin test"
"start": "zen start -d android -d ios",
"android": "zen start -e android -d ios -d web",
"ios": "zen start -e ios -d android -d web",
"build": "zen build"
},

@@ -12,0 +11,0 @@ "workspaces": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc