create-payload-app 0.3.7 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/lib/constants.js +4 -0
- package/dist/lib/getPackageManager.js +69 -0
- package/dist/lib/getPayloadVersion.js +75 -0
- package/dist/templates/js-blank/package.json +1 -1
- package/dist/templates/js-blank/server.js +1 -5
- package/dist/templates/js-blog/package.json +1 -1
- package/dist/templates/js-blog/server.js +1 -5
- package/dist/templates/js-todo/package.json +1 -1
- package/dist/templates/js-todo/server.js +1 -5
- package/dist/templates/ts-blank/package.json +6 -3
- package/dist/templates/ts-blank/src/payload.config.ts +4 -1
- package/dist/templates/ts-blank/src/server.ts +1 -5
- package/dist/templates/ts-blank/tsconfig.json +11 -2
- package/dist/templates/ts-blog/package.json +6 -3
- package/dist/templates/ts-blog/src/payload.config.ts +3 -0
- package/dist/templates/ts-blog/src/server.ts +1 -5
- package/dist/templates/ts-blog/tsconfig.json +11 -2
- package/dist/templates/ts-todo/package.json +6 -3
- package/dist/templates/ts-todo/src/payload.config.ts +3 -0
- package/dist/templates/ts-todo/src/server.ts +1 -5
- package/dist/templates/ts-todo/tsconfig.json +11 -2
- package/dist/utils/telemetry.js +44 -0
- package/package.json +2 -2
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (_) try {
|
18
|
+
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;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
40
|
+
};
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
42
|
+
exports.getPackageManager = void 0;
|
43
|
+
var command_exists_1 = __importDefault(require("command-exists"));
|
44
|
+
function getPackageManager(args) {
|
45
|
+
return __awaiter(this, void 0, void 0, function () {
|
46
|
+
var packageManager, error_1;
|
47
|
+
return __generator(this, function (_a) {
|
48
|
+
switch (_a.label) {
|
49
|
+
case 0:
|
50
|
+
if (!args['--use-npm']) return [3 /*break*/, 1];
|
51
|
+
packageManager = 'npm';
|
52
|
+
return [3 /*break*/, 4];
|
53
|
+
case 1:
|
54
|
+
_a.trys.push([1, 3, , 4]);
|
55
|
+
return [4 /*yield*/, (0, command_exists_1.default)('yarn')];
|
56
|
+
case 2:
|
57
|
+
_a.sent();
|
58
|
+
packageManager = 'yarn';
|
59
|
+
return [3 /*break*/, 4];
|
60
|
+
case 3:
|
61
|
+
error_1 = _a.sent();
|
62
|
+
packageManager = 'npm';
|
63
|
+
return [3 /*break*/, 4];
|
64
|
+
case 4: return [2 /*return*/, packageManager];
|
65
|
+
}
|
66
|
+
});
|
67
|
+
});
|
68
|
+
}
|
69
|
+
exports.getPackageManager = getPackageManager;
|
@@ -0,0 +1,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (_) try {
|
18
|
+
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;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
40
|
+
};
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
42
|
+
exports.getLatestPayloadVersion = void 0;
|
43
|
+
var execa_1 = __importDefault(require("execa"));
|
44
|
+
var log_1 = require("../utils/log");
|
45
|
+
function getLatestPayloadVersion(betaFlag) {
|
46
|
+
if (betaFlag === void 0) { betaFlag = false; }
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
48
|
+
var packageWithTag, stdout, err_1, msg;
|
49
|
+
return __generator(this, function (_a) {
|
50
|
+
switch (_a.label) {
|
51
|
+
case 0:
|
52
|
+
_a.trys.push([0, 2, , 3]);
|
53
|
+
packageWithTag = 'payload';
|
54
|
+
if (betaFlag)
|
55
|
+
packageWithTag += '@beta';
|
56
|
+
return [4 /*yield*/, (0, execa_1.default)("npm info ".concat(packageWithTag, " version"), [], {
|
57
|
+
shell: true,
|
58
|
+
})];
|
59
|
+
case 1:
|
60
|
+
stdout = (_a.sent()).stdout;
|
61
|
+
return [2 /*return*/, "^".concat(stdout)];
|
62
|
+
case 2:
|
63
|
+
err_1 = _a.sent();
|
64
|
+
msg = "Unable to get latest Payload version.";
|
65
|
+
if (err_1 instanceof Error)
|
66
|
+
msg += " ".concat(err_1.message);
|
67
|
+
(0, log_1.error)(msg);
|
68
|
+
process.exit(1);
|
69
|
+
return [3 /*break*/, 3];
|
70
|
+
case 3: return [2 /*return*/];
|
71
|
+
}
|
72
|
+
});
|
73
|
+
});
|
74
|
+
}
|
75
|
+
exports.getLatestPayloadVersion = getLatestPayloadVersion;
|
@@ -13,10 +13,6 @@ app.get('/', (_, res) => {
|
|
13
13
|
payload.init({
|
14
14
|
secret: process.env.PAYLOAD_SECRET,
|
15
15
|
mongoURL: process.env.MONGODB_URI,
|
16
|
-
|
17
|
-
// Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
|
18
|
-
// license: process.env.PAYLOAD_LICENSE_KEY,
|
19
|
-
|
20
16
|
express: app,
|
21
17
|
onInit: () => {
|
22
18
|
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
|
@@ -25,4 +21,4 @@ payload.init({
|
|
25
21
|
|
26
22
|
// Add your own express routes here
|
27
23
|
|
28
|
-
app.listen(3000);
|
24
|
+
app.listen(3000);
|
@@ -13,10 +13,6 @@ app.get('/', (_, res) => {
|
|
13
13
|
payload.init({
|
14
14
|
secret: process.env.PAYLOAD_SECRET,
|
15
15
|
mongoURL: process.env.MONGODB_URI,
|
16
|
-
|
17
|
-
// Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
|
18
|
-
// license: process.env.PAYLOAD_LICENSE_KEY,
|
19
|
-
|
20
16
|
express: app,
|
21
17
|
onInit: () => {
|
22
18
|
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
|
@@ -25,4 +21,4 @@ payload.init({
|
|
25
21
|
|
26
22
|
// Add your own express routes here
|
27
23
|
|
28
|
-
app.listen(3000);
|
24
|
+
app.listen(3000);
|
@@ -13,10 +13,6 @@ app.get('/', (_, res) => {
|
|
13
13
|
payload.init({
|
14
14
|
secret: process.env.PAYLOAD_SECRET,
|
15
15
|
mongoURL: process.env.MONGODB_URI,
|
16
|
-
|
17
|
-
// Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
|
18
|
-
// license: process.env.PAYLOAD_LICENSE_KEY,
|
19
|
-
|
20
16
|
express: app,
|
21
17
|
onInit: () => {
|
22
18
|
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`);
|
@@ -25,4 +21,4 @@ payload.init({
|
|
25
21
|
|
26
22
|
// Add your own express routes here
|
27
23
|
|
28
|
-
app.listen(3000);
|
24
|
+
app.listen(3000);
|
@@ -8,12 +8,14 @@
|
|
8
8
|
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
|
9
9
|
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
|
10
10
|
"build:server": "tsc",
|
11
|
-
"build": "yarn build:payload && yarn build:server",
|
11
|
+
"build": "yarn copyfiles && yarn build:payload && yarn build:server",
|
12
12
|
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
|
13
|
-
"
|
13
|
+
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
|
14
|
+
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
|
15
|
+
"generate:graphQLSchema": "PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
|
14
16
|
},
|
15
17
|
"dependencies": {
|
16
|
-
"payload": "0.
|
18
|
+
"payload": "1.0.8",
|
17
19
|
"dotenv": "^8.2.0",
|
18
20
|
"express": "^4.17.1"
|
19
21
|
},
|
@@ -22,6 +24,7 @@
|
|
22
24
|
"cross-env": "^7.0.3",
|
23
25
|
"nodemon": "^2.0.6",
|
24
26
|
"ts-node": "^9.1.1",
|
27
|
+
"copyfiles": "^2.4.1",
|
25
28
|
"typescript": "^4.1.3"
|
26
29
|
}
|
27
30
|
}
|
@@ -14,6 +14,9 @@ export default buildConfig({
|
|
14
14
|
// Examples,
|
15
15
|
],
|
16
16
|
typescript: {
|
17
|
-
outputFile: path.resolve(__dirname, 'payload-types.ts')
|
17
|
+
outputFile: path.resolve(__dirname, 'payload-types.ts'),
|
18
|
+
},
|
19
|
+
graphQL: {
|
20
|
+
schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
|
18
21
|
},
|
19
22
|
});
|
@@ -13,10 +13,6 @@ app.get('/', (_, res) => {
|
|
13
13
|
payload.init({
|
14
14
|
secret: process.env.PAYLOAD_SECRET,
|
15
15
|
mongoURL: process.env.MONGODB_URI,
|
16
|
-
|
17
|
-
// Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
|
18
|
-
// license: process.env.PAYLOAD_LICENSE_KEY,
|
19
|
-
|
20
16
|
express: app,
|
21
17
|
onInit: () => {
|
22
18
|
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
|
@@ -25,4 +21,4 @@ payload.init({
|
|
25
21
|
|
26
22
|
// Add your own express routes here
|
27
23
|
|
28
|
-
app.listen(3000);
|
24
|
+
app.listen(3000);
|
@@ -6,14 +6,23 @@
|
|
6
6
|
"dom.iterable",
|
7
7
|
"esnext"
|
8
8
|
],
|
9
|
+
"allowJs": true,
|
9
10
|
"strict": false,
|
10
11
|
"esModuleInterop": true,
|
11
12
|
"skipLibCheck": true,
|
12
13
|
"outDir": "./dist",
|
13
14
|
"rootDir": "./src",
|
14
|
-
"jsx": "react"
|
15
|
+
"jsx": "react"
|
15
16
|
},
|
17
|
+
"include": [
|
18
|
+
"src"
|
19
|
+
],
|
20
|
+
"exclude": [
|
21
|
+
"node_modules",
|
22
|
+
"dist",
|
23
|
+
"build",
|
24
|
+
],
|
16
25
|
"ts-node": {
|
17
26
|
"transpileOnly": true
|
18
27
|
}
|
19
|
-
}
|
28
|
+
}
|
@@ -8,12 +8,14 @@
|
|
8
8
|
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
|
9
9
|
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
|
10
10
|
"build:server": "tsc",
|
11
|
-
"build": "yarn build:payload && yarn build:server",
|
11
|
+
"build": "yarn copyfiles && yarn build:payload && yarn build:server",
|
12
12
|
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
|
13
|
-
"
|
13
|
+
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
|
14
|
+
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
|
15
|
+
"generate:graphQLSchema": "PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
|
14
16
|
},
|
15
17
|
"dependencies": {
|
16
|
-
"payload": "0.
|
18
|
+
"payload": "1.0.8",
|
17
19
|
"dotenv": "^8.2.0",
|
18
20
|
"express": "^4.17.1"
|
19
21
|
},
|
@@ -22,6 +24,7 @@
|
|
22
24
|
"cross-env": "^7.0.3",
|
23
25
|
"nodemon": "^2.0.6",
|
24
26
|
"ts-node": "^9.1.1",
|
27
|
+
"copyfiles": "^2.4.1",
|
25
28
|
"typescript": "^4.1.3"
|
26
29
|
}
|
27
30
|
}
|
@@ -13,10 +13,6 @@ app.get('/', (_, res) => {
|
|
13
13
|
payload.init({
|
14
14
|
secret: process.env.PAYLOAD_SECRET,
|
15
15
|
mongoURL: process.env.MONGODB_URI,
|
16
|
-
|
17
|
-
// Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
|
18
|
-
// license: process.env.PAYLOAD_LICENSE_KEY,
|
19
|
-
|
20
16
|
express: app,
|
21
17
|
onInit: () => {
|
22
18
|
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
|
@@ -25,4 +21,4 @@ payload.init({
|
|
25
21
|
|
26
22
|
// Add your own express routes here
|
27
23
|
|
28
|
-
app.listen(3000);
|
24
|
+
app.listen(3000);
|
@@ -6,14 +6,23 @@
|
|
6
6
|
"dom.iterable",
|
7
7
|
"esnext"
|
8
8
|
],
|
9
|
+
"allowJs": true,
|
9
10
|
"strict": false,
|
10
11
|
"esModuleInterop": true,
|
11
12
|
"skipLibCheck": true,
|
12
13
|
"outDir": "./dist",
|
13
14
|
"rootDir": "./src",
|
14
|
-
"jsx": "react"
|
15
|
+
"jsx": "react"
|
15
16
|
},
|
17
|
+
"include": [
|
18
|
+
"src"
|
19
|
+
],
|
20
|
+
"exclude": [
|
21
|
+
"node_modules",
|
22
|
+
"dist",
|
23
|
+
"build",
|
24
|
+
],
|
16
25
|
"ts-node": {
|
17
26
|
"transpileOnly": true
|
18
27
|
}
|
19
|
-
}
|
28
|
+
}
|
@@ -8,12 +8,14 @@
|
|
8
8
|
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts nodemon",
|
9
9
|
"build:payload": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload build",
|
10
10
|
"build:server": "tsc",
|
11
|
-
"build": "yarn build:payload && yarn build:server",
|
11
|
+
"build": "yarn copyfiles && yarn build:payload && yarn build:server",
|
12
12
|
"serve": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",
|
13
|
-
"
|
13
|
+
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png}\" dist/",
|
14
|
+
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:types",
|
15
|
+
"generate:graphQLSchema": "PAYLOAD_CONFIG_PATH=src/payload.config.ts payload generate:graphQLSchema"
|
14
16
|
},
|
15
17
|
"dependencies": {
|
16
|
-
"payload": "0.
|
18
|
+
"payload": "1.0.8",
|
17
19
|
"dotenv": "^8.2.0",
|
18
20
|
"express": "^4.17.1"
|
19
21
|
},
|
@@ -22,6 +24,7 @@
|
|
22
24
|
"cross-env": "^7.0.3",
|
23
25
|
"nodemon": "^2.0.6",
|
24
26
|
"ts-node": "^9.1.1",
|
27
|
+
"copyfiles": "^2.4.1",
|
25
28
|
"typescript": "^4.1.3"
|
26
29
|
}
|
27
30
|
}
|
@@ -13,10 +13,6 @@ app.get('/', (_, res) => {
|
|
13
13
|
payload.init({
|
14
14
|
secret: process.env.PAYLOAD_SECRET,
|
15
15
|
mongoURL: process.env.MONGODB_URI,
|
16
|
-
|
17
|
-
// Only needed to deploy publicly. Get free Personal license at https://payloadcms.com.
|
18
|
-
// license: process.env.PAYLOAD_LICENSE_KEY,
|
19
|
-
|
20
16
|
express: app,
|
21
17
|
onInit: () => {
|
22
18
|
payload.logger.info(`Payload Admin URL: ${payload.getAdminURL()}`)
|
@@ -25,4 +21,4 @@ payload.init({
|
|
25
21
|
|
26
22
|
// Add your own express routes here
|
27
23
|
|
28
|
-
app.listen(3000);
|
24
|
+
app.listen(3000);
|
@@ -6,14 +6,23 @@
|
|
6
6
|
"dom.iterable",
|
7
7
|
"esnext"
|
8
8
|
],
|
9
|
+
"allowJs": true,
|
9
10
|
"strict": false,
|
10
11
|
"esModuleInterop": true,
|
11
12
|
"skipLibCheck": true,
|
12
13
|
"outDir": "./dist",
|
13
14
|
"rootDir": "./src",
|
14
|
-
"jsx": "react"
|
15
|
+
"jsx": "react"
|
15
16
|
},
|
17
|
+
"include": [
|
18
|
+
"src"
|
19
|
+
],
|
20
|
+
"exclude": [
|
21
|
+
"node_modules",
|
22
|
+
"dist",
|
23
|
+
"build",
|
24
|
+
],
|
16
25
|
"ts-node": {
|
17
26
|
"transpileOnly": true
|
18
27
|
}
|
19
|
-
}
|
28
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.sendAnonymousAnalytics = void 0;
|
7
|
+
var analytics_node_1 = __importDefault(require("analytics-node"));
|
8
|
+
var crypto_1 = require("crypto");
|
9
|
+
var os_1 = __importDefault(require("os"));
|
10
|
+
var constants_1 = require("../lib/constants");
|
11
|
+
var analytics = new analytics_node_1.default(constants_1.SEGMENT_WRITE_KEY, { flushAt: 1 });
|
12
|
+
var userId;
|
13
|
+
function sendAnonymousAnalytics(meta) {
|
14
|
+
try {
|
15
|
+
var projectDir = meta.projectDir, template = meta.template, packageManager = meta.packageManager;
|
16
|
+
userId = userId !== null && userId !== void 0 ? userId : oneWayHash(projectDir);
|
17
|
+
analytics.track({
|
18
|
+
userId: userId,
|
19
|
+
event: 'ProjectInitiated',
|
20
|
+
properties: {
|
21
|
+
systemPlatform: os_1.default.platform(),
|
22
|
+
systemRelease: os_1.default.release(),
|
23
|
+
systemArchitecture: os_1.default.arch(),
|
24
|
+
nodeVersion: process.version,
|
25
|
+
nodeEnv: process.env.NODE_ENV,
|
26
|
+
template: template,
|
27
|
+
packageManager: packageManager,
|
28
|
+
},
|
29
|
+
});
|
30
|
+
}
|
31
|
+
catch (error) {
|
32
|
+
// Eat any errors
|
33
|
+
}
|
34
|
+
}
|
35
|
+
exports.sendAnonymousAnalytics = sendAnonymousAnalytics;
|
36
|
+
/** Hash values one-way to ensure anonymity */
|
37
|
+
function oneWayHash(payload) {
|
38
|
+
var hash = (0, crypto_1.createHash)('sha256');
|
39
|
+
// Prepend salt to ensure truly one-way hashing.
|
40
|
+
hash.update((0, crypto_1.randomBytes)(16).toString('hex'));
|
41
|
+
// This appends the payload to the hash. The salt is from prior update still present!
|
42
|
+
hash.update(payload);
|
43
|
+
return hash.digest('hex');
|
44
|
+
}
|
package/package.json
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
"typecheck": "tsc --noEmit",
|
11
11
|
"lint": "eslint \"src/**/*.ts\"",
|
12
12
|
"test": "jest",
|
13
|
-
"
|
13
|
+
"prepublishOnly": "yarn test && yarn build"
|
14
14
|
},
|
15
15
|
"files": [
|
16
16
|
"package.json",
|
@@ -31,7 +31,7 @@
|
|
31
31
|
"prompts": "^2.4.0",
|
32
32
|
"terminal-link": "^2.1.1"
|
33
33
|
},
|
34
|
-
"version": "0.3.
|
34
|
+
"version": "0.3.9",
|
35
35
|
"devDependencies": {
|
36
36
|
"@types/command-exists": "^1.2.0",
|
37
37
|
"@types/degit": "^2.8.3",
|