create-payload-app
Advanced tools
Comparing version 0.5.2 to 1.0.0-beta.0
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var main_1 = require("./main"); | ||
var log_1 = require("./utils/log"); | ||
function main() { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, new main_1.Main().init()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
const _main = require("./main"); | ||
const _log = require("./utils/log"); | ||
async function main() { | ||
await new _main.Main().init(); | ||
} | ||
main().catch(function (e) { | ||
return (0, log_1.error)("An error has occurred: ".concat(e instanceof Error ? e.message : e)); | ||
}); | ||
main().catch((e)=>(0, _log.error)(`An error has occurred: ${e instanceof Error ? e.message : e}`)); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBNYWluIH0gZnJvbSAnLi9tYWluJ1xuaW1wb3J0IHsgZXJyb3IgfSBmcm9tICcuL3V0aWxzL2xvZydcblxuYXN5bmMgZnVuY3Rpb24gbWFpbigpOiBQcm9taXNlPHZvaWQ+IHtcbiAgYXdhaXQgbmV3IE1haW4oKS5pbml0KClcbn1cblxubWFpbigpLmNhdGNoKChlKSA9PiBlcnJvcihgQW4gZXJyb3IgaGFzIG9jY3VycmVkOiAke2UgaW5zdGFuY2VvZiBFcnJvciA/IGUubWVzc2FnZSA6IGV9YCkpXG4iXSwibmFtZXMiOlsibWFpbiIsIk1haW4iLCJpbml0IiwiY2F0Y2giLCJlIiwiZXJyb3IiLCJFcnJvciIsIm1lc3NhZ2UiXSwibWFwcGluZ3MiOiI7Ozs7c0JBQXFCO3FCQUNDO0FBRXRCLGVBQWVBO0lBQ2IsTUFBTSxJQUFJQyxVQUFJLEdBQUdDLElBQUk7QUFDdkI7QUFFQUYsT0FBT0csS0FBSyxDQUFDLENBQUNDLElBQU1DLElBQUFBLFVBQUssRUFBQyxDQUFDLHVCQUF1QixFQUFFRCxhQUFhRSxRQUFRRixFQUFFRyxPQUFPLEdBQUdILEVBQUUsQ0FBQyJ9 |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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 (g && (g = 0, op[0] && (_ = 0)), _) 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; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "configurePayloadConfig", { | ||
enumerable: true, | ||
get: function() { | ||
return configurePayloadConfig; | ||
} | ||
}); | ||
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _log = require("../utils/log"); | ||
const _packages = require("./packages"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
async function configurePayloadConfig(args) { | ||
if (!args.dbDetails) { | ||
return; | ||
} | ||
// Update package.json | ||
const packageJsonPath = _path.default.resolve(args.projectDir, 'package.json'); | ||
try { | ||
const packageObj = await _fsextra.default.readJson(packageJsonPath); | ||
packageObj.dependencies['payload'] = '^2.0.0'; | ||
const dbPackage = _packages.dbPackages[args.dbDetails.type]; | ||
const bundlerPackage = _packages.bundlerPackages['webpack']; | ||
const editorPackage = _packages.editorPackages['slate']; | ||
// Delete all other db adapters | ||
Object.values(_packages.dbPackages).forEach((p)=>{ | ||
if (p.packageName !== dbPackage.packageName) { | ||
delete packageObj.dependencies[p.packageName]; | ||
} | ||
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 }; | ||
}); | ||
packageObj.dependencies[dbPackage.packageName] = dbPackage.version; | ||
packageObj.dependencies[bundlerPackage.packageName] = bundlerPackage.version; | ||
packageObj.dependencies[editorPackage.packageName] = editorPackage.version; | ||
await _fsextra.default.writeJson(packageJsonPath, packageObj, { | ||
spaces: 2 | ||
}); | ||
} catch (err) { | ||
(0, _log.warning)('Unable to update name in package.json'); | ||
} | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
try { | ||
const possiblePaths = [ | ||
_path.default.resolve(args.projectDir, 'src/payload.config.ts'), | ||
_path.default.resolve(args.projectDir, 'src/payload/payload.config.ts') | ||
]; | ||
let payloadConfigPath; | ||
possiblePaths.forEach((p)=>{ | ||
if (_fsextra.default.pathExistsSync(p) && !payloadConfigPath) { | ||
payloadConfigPath = p; | ||
} | ||
}); | ||
if (!payloadConfigPath) { | ||
(0, _log.warning)('Unable to update payload.config.ts with plugins'); | ||
return; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.configurePayloadConfig = void 0; | ||
var fs_extra_1 = __importDefault(require("fs-extra")); | ||
var path_1 = __importDefault(require("path")); | ||
var log_1 = require("../utils/log"); | ||
var packages_1 = require("./packages"); | ||
/** Update payload config with necessary imports and adapters */ | ||
function configurePayloadConfig(args) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var packageJsonPath, packageObj_1, dbPackage_1, bundlerPackage, editorPackage, err_1, possiblePaths, payloadConfigPath_1, configContent, configLines_1, dbReplacement_1, bundlerReplacement_1, editorReplacement_1, dbConfigStartLineIndex_1, dbConfigEndLineIndex_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!args.dbDetails) { | ||
return [2 /*return*/]; | ||
} | ||
packageJsonPath = path_1.default.resolve(args.projectDir, 'package.json'); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 4, , 5]); | ||
return [4 /*yield*/, fs_extra_1.default.readJson(packageJsonPath)]; | ||
case 2: | ||
packageObj_1 = _a.sent(); | ||
packageObj_1.dependencies['payload'] = '^2.0.0'; | ||
dbPackage_1 = packages_1.dbPackages[args.dbDetails.type]; | ||
bundlerPackage = packages_1.bundlerPackages['webpack']; | ||
editorPackage = packages_1.editorPackages['slate']; | ||
// Delete all other db adapters | ||
Object.values(packages_1.dbPackages).forEach(function (p) { | ||
if (p.packageName !== dbPackage_1.packageName) { | ||
delete packageObj_1.dependencies[p.packageName]; | ||
} | ||
}); | ||
packageObj_1.dependencies[dbPackage_1.packageName] = dbPackage_1.version; | ||
packageObj_1.dependencies[bundlerPackage.packageName] = bundlerPackage.version; | ||
packageObj_1.dependencies[editorPackage.packageName] = editorPackage.version; | ||
return [4 /*yield*/, fs_extra_1.default.writeJson(packageJsonPath, packageObj_1, { spaces: 2 })]; | ||
case 3: | ||
_a.sent(); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
err_1 = _a.sent(); | ||
(0, log_1.warning)('Unable to update name in package.json'); | ||
return [3 /*break*/, 5]; | ||
case 5: | ||
try { | ||
possiblePaths = [ | ||
path_1.default.resolve(args.projectDir, 'src/payload.config.ts'), | ||
path_1.default.resolve(args.projectDir, 'src/payload/payload.config.ts'), | ||
]; | ||
possiblePaths.forEach(function (p) { | ||
if (fs_extra_1.default.pathExistsSync(p) && !payloadConfigPath_1) { | ||
payloadConfigPath_1 = p; | ||
} | ||
}); | ||
if (!payloadConfigPath_1) { | ||
(0, log_1.warning)('Unable to update payload.config.ts with plugins'); | ||
return [2 /*return*/]; | ||
} | ||
configContent = fs_extra_1.default.readFileSync(payloadConfigPath_1, 'utf-8'); | ||
configLines_1 = configContent.split('\n'); | ||
dbReplacement_1 = packages_1.dbPackages[args.dbDetails.type]; | ||
bundlerReplacement_1 = packages_1.bundlerPackages['webpack']; | ||
editorReplacement_1 = packages_1.editorPackages['slate']; | ||
configLines_1.forEach(function (l, i) { | ||
if (l.includes('// database-adapter-import')) { | ||
configLines_1[i] = dbReplacement_1.importReplacement; | ||
} | ||
if (l.includes('// bundler-import')) { | ||
configLines_1[i] = bundlerReplacement_1.importReplacement; | ||
} | ||
if (l.includes('// bundler-config')) { | ||
configLines_1[i] = bundlerReplacement_1.configReplacement; | ||
} | ||
if (l.includes('// editor-import')) { | ||
configLines_1[i] = editorReplacement_1.importReplacement; | ||
} | ||
if (l.includes('// editor-config')) { | ||
configLines_1[i] = editorReplacement_1.configReplacement; | ||
} | ||
if (l.includes('// database-adapter-config-start')) { | ||
dbConfigStartLineIndex_1 = i; | ||
} | ||
if (l.includes('// database-adapter-config-end')) { | ||
dbConfigEndLineIndex_1 = i; | ||
} | ||
}); | ||
if (!dbConfigStartLineIndex_1 || !dbConfigEndLineIndex_1) { | ||
(0, log_1.warning)('Unable to update payload.config.ts with database adapter import'); | ||
} | ||
else { | ||
// Replaces lines between `// database-adapter-config-start` and `// database-adapter-config-end` | ||
configLines_1.splice.apply(configLines_1, __spreadArray([dbConfigStartLineIndex_1, | ||
dbConfigEndLineIndex_1 - dbConfigStartLineIndex_1 + 1], dbReplacement_1.configReplacement, false)); | ||
} | ||
fs_extra_1.default.writeFileSync(payloadConfigPath_1, configLines_1.join('\n')); | ||
} | ||
catch (err) { | ||
(0, log_1.warning)('Unable to update payload.config.ts with plugins'); | ||
} | ||
return [2 /*return*/]; | ||
const configContent = _fsextra.default.readFileSync(payloadConfigPath, 'utf-8'); | ||
const configLines = configContent.split('\n'); | ||
const dbReplacement = _packages.dbPackages[args.dbDetails.type]; | ||
const bundlerReplacement = _packages.bundlerPackages['webpack']; | ||
const editorReplacement = _packages.editorPackages['slate']; | ||
let dbConfigStartLineIndex; | ||
let dbConfigEndLineIndex; | ||
configLines.forEach((l, i)=>{ | ||
if (l.includes('// database-adapter-import')) { | ||
configLines[i] = dbReplacement.importReplacement; | ||
} | ||
if (l.includes('// bundler-import')) { | ||
configLines[i] = bundlerReplacement.importReplacement; | ||
} | ||
if (l.includes('// bundler-config')) { | ||
configLines[i] = bundlerReplacement.configReplacement; | ||
} | ||
if (l.includes('// editor-import')) { | ||
configLines[i] = editorReplacement.importReplacement; | ||
} | ||
if (l.includes('// editor-config')) { | ||
configLines[i] = editorReplacement.configReplacement; | ||
} | ||
if (l.includes('// database-adapter-config-start')) { | ||
dbConfigStartLineIndex = i; | ||
} | ||
if (l.includes('// database-adapter-config-end')) { | ||
dbConfigEndLineIndex = i; | ||
} | ||
}); | ||
}); | ||
if (!dbConfigStartLineIndex || !dbConfigEndLineIndex) { | ||
(0, _log.warning)('Unable to update payload.config.ts with database adapter import'); | ||
} else { | ||
// Replaces lines between `// database-adapter-config-start` and `// database-adapter-config-end` | ||
configLines.splice(dbConfigStartLineIndex, dbConfigEndLineIndex - dbConfigStartLineIndex + 1, ...dbReplacement.configReplacement); | ||
} | ||
_fsextra.default.writeFileSync(payloadConfigPath, configLines.join('\n')); | ||
} catch (err) { | ||
(0, _log.warning)('Unable to update payload.config.ts with plugins'); | ||
} | ||
} | ||
exports.configurePayloadConfig = configurePayloadConfig; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY29uZmlndXJlLXBheWxvYWQtY29uZmlnLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBmc2UgZnJvbSAnZnMtZXh0cmEnXG5pbXBvcnQgcGF0aCBmcm9tICdwYXRoJ1xuXG5pbXBvcnQgdHlwZSB7IERiRGV0YWlscyB9IGZyb20gJy4uL3R5cGVzJ1xuXG5pbXBvcnQgeyB3YXJuaW5nIH0gZnJvbSAnLi4vdXRpbHMvbG9nJ1xuaW1wb3J0IHsgYnVuZGxlclBhY2thZ2VzL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NTLGlCQUFpQjtRQUV0QztRQUVBcEMsZ0JBQUcsQ0FBQ3NDLGFBQWEsQ0FBQ2pCLG1CQUFtQkksWUFBWWMsSUFBSSxDQUFDO0lBQ3hELEVBQUUsT0FBT3JCLEtBQWM7UUFDckJDLElBQUFBLFlBQU8sRUFBQztJQUNWO0FBQ0YifQ== |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
}; | ||
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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
} | ||
_export(exports, { | ||
createProject: function() { | ||
return createProject; | ||
}, | ||
updatePackageJSON: function() { | ||
return updatePackageJSON; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.updatePackageJSON = exports.createProject = void 0; | ||
var path_1 = __importDefault(require("path")); | ||
var chalk_1 = __importDefault(require("chalk")); | ||
var fs_extra_1 = __importDefault(require("fs-extra")); | ||
var execa_1 = __importDefault(require("execa")); | ||
var ora_1 = __importDefault(require("ora")); | ||
var degit_1 = __importDefault(require("degit")); | ||
var log_1 = require("../utils/log"); | ||
var configure_payload_config_1 = require("./configure-payload-config"); | ||
function createOrFindProjectDir(projectDir) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var pathExists; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, fs_extra_1.default.pathExists(projectDir)]; | ||
case 1: | ||
pathExists = _a.sent(); | ||
if (!!pathExists) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, fs_extra_1.default.mkdir(projectDir)]; | ||
case 2: | ||
_a.sent(); | ||
_a.label = 3; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}); | ||
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk")); | ||
const _degit = /*#__PURE__*/ _interop_require_default(require("degit")); | ||
const _execa = /*#__PURE__*/ _interop_require_default(require("execa")); | ||
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra")); | ||
const _ora = /*#__PURE__*/ _interop_require_default(require("ora")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _log = require("../utils/log"); | ||
const _configurepayloadconfig = require("./configure-payload-config"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
function installDeps(args) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var cliArgs, projectDir, packageManager, installCmd, err_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
cliArgs = args.cliArgs, projectDir = args.projectDir, packageManager = args.packageManager; | ||
if (cliArgs['--no-deps']) { | ||
return [2 /*return*/, true]; | ||
} | ||
installCmd = 'npm install --legacy-peer-deps'; | ||
if (packageManager === 'yarn') { | ||
installCmd = 'yarn'; | ||
} | ||
else if (packageManager === 'pnpm') { | ||
installCmd = 'pnpm install'; | ||
} | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, execa_1.default.command(installCmd, { | ||
cwd: path_1.default.resolve(projectDir), | ||
})]; | ||
case 2: | ||
_a.sent(); | ||
return [2 /*return*/, true]; | ||
case 3: | ||
err_1 = _a.sent(); | ||
console.log({ err: err_1 }); | ||
return [2 /*return*/, false]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
async function createOrFindProjectDir(projectDir) { | ||
const pathExists = await _fsextra.default.pathExists(projectDir); | ||
if (!pathExists) { | ||
await _fsextra.default.mkdir(projectDir); | ||
} | ||
} | ||
async function installDeps(args) { | ||
const { cliArgs, packageManager, projectDir } = args; | ||
if (cliArgs['--no-deps']) { | ||
return true; | ||
} | ||
let installCmd = 'npm install --legacy-peer-deps'; | ||
if (packageManager === 'yarn') { | ||
installCmd = 'yarn'; | ||
} else if (packageManager === 'pnpm') { | ||
installCmd = 'pnpm install'; | ||
} | ||
try { | ||
await _execa.default.command(installCmd, { | ||
cwd: _path.default.resolve(projectDir) | ||
}); | ||
}); | ||
return true; | ||
} catch (err) { | ||
console.log({ | ||
err | ||
}); | ||
return false; | ||
} | ||
} | ||
function createProject(args) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var cliArgs, projectName, projectDir, template, packageManager, dbDetails, emitter, spinner, lockPath, result; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
cliArgs = args.cliArgs, projectName = args.projectName, projectDir = args.projectDir, template = args.template, packageManager = args.packageManager, dbDetails = args.dbDetails; | ||
return [4 /*yield*/, createOrFindProjectDir(projectDir)]; | ||
case 1: | ||
_a.sent(); | ||
console.log("\n Creating project in ".concat(chalk_1.default.green(path_1.default.resolve(projectDir)), "\n")); | ||
if (!('url' in template)) return [3 /*break*/, 3]; | ||
emitter = (0, degit_1.default)(template.url); | ||
return [4 /*yield*/, emitter.clone(projectDir)]; | ||
case 2: | ||
_a.sent(); | ||
_a.label = 3; | ||
case 3: | ||
spinner = (0, ora_1.default)('Checking latest Payload version...').start(); | ||
return [4 /*yield*/, updatePackageJSON({ projectName: projectName, projectDir: projectDir })]; | ||
case 4: | ||
_a.sent(); | ||
return [4 /*yield*/, (0, configure_payload_config_1.configurePayloadConfig)({ projectDir: projectDir, dbDetails: dbDetails }) | ||
// Remove yarn.lock file. This is only desired in Payload Cloud. | ||
]; | ||
case 5: | ||
_a.sent(); | ||
lockPath = path_1.default.resolve(projectDir, 'yarn.lock'); | ||
if (!fs_extra_1.default.existsSync(lockPath)) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, fs_extra_1.default.remove(lockPath)]; | ||
case 6: | ||
_a.sent(); | ||
_a.label = 7; | ||
case 7: | ||
spinner.text = 'Installing dependencies...'; | ||
return [4 /*yield*/, installDeps({ cliArgs: cliArgs, projectDir: projectDir, packageManager: packageManager })]; | ||
case 8: | ||
result = _a.sent(); | ||
spinner.stop(); | ||
spinner.clear(); | ||
if (result) { | ||
(0, log_1.success)('Dependencies installed'); | ||
} | ||
else { | ||
(0, log_1.error)('Error installing dependencies'); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
async function createProject(args) { | ||
const { cliArgs, dbDetails, packageManager, projectDir, projectName, template } = args; | ||
await createOrFindProjectDir(projectDir); | ||
console.log(`\n Creating project in ${_chalk.default.green(_path.default.resolve(projectDir))}\n`); | ||
if ('url' in template) { | ||
const emitter = (0, _degit.default)(template.url); | ||
await emitter.clone(projectDir); | ||
} | ||
const spinner = (0, _ora.default)('Checking latest Payload version...').start(); | ||
await updatePackageJSON({ | ||
projectDir, | ||
projectName | ||
}); | ||
await (0, _configurepayloadconfig.configurePayloadConfig)({ | ||
dbDetails, | ||
projectDir | ||
}); | ||
// Remove yarn.lock file. This is only desired in Payload Cloud. | ||
const lockPath = _path.default.resolve(projectDir, 'yarn.lock'); | ||
if (_fsextra.default.existsSync(lockPath)) { | ||
await _fsextra.default.remove(lockPath); | ||
} | ||
spinner.text = 'Installing dependencies...'; | ||
const result = await installDeps({ | ||
cliArgs, | ||
packageManager, | ||
projectDir | ||
}); | ||
spinner.stop(); | ||
spinner.clear(); | ||
if (result) { | ||
(0, _log.success)('Dependencies installed'); | ||
} else { | ||
(0, _log.error)('Error installing dependencies'); | ||
} | ||
} | ||
exports.createProject = createProject; | ||
function updatePackageJSON(args) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var projectName, projectDir, packageJsonPath, packageObj, err_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
projectName = args.projectName, projectDir = args.projectDir; | ||
packageJsonPath = path_1.default.resolve(projectDir, 'package.json'); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 4, , 5]); | ||
return [4 /*yield*/, fs_extra_1.default.readJson(packageJsonPath)]; | ||
case 2: | ||
packageObj = _a.sent(); | ||
packageObj.name = projectName; | ||
return [4 /*yield*/, fs_extra_1.default.writeJson(packageJsonPath, packageObj, { spaces: 2 })]; | ||
case 3: | ||
_a.sent(); | ||
return [3 /*break*/, 5]; | ||
case 4: | ||
err_2 = _a.sent(); | ||
(0, log_1.warning)('Unable to update name in package.json'); | ||
return [3 /*break*/, 5]; | ||
case 5: return [2 /*return*/]; | ||
} | ||
async function updatePackageJSON(args) { | ||
const { projectDir, projectName } = args; | ||
const packageJsonPath = _path.default.resolve(projectDir, 'package.json'); | ||
try { | ||
const packageObj = await _fsextra.default.readJson(packageJsonPath); | ||
packageObj.name = projectName; | ||
await _fsextra.default.writeJson(packageJsonPath, packageObj, { | ||
spaces: 2 | ||
}); | ||
}); | ||
} catch (err) { | ||
(0, _log.warning)('Unable to update name in package.json'); | ||
} | ||
} | ||
exports.updatePackageJSON = updatePackageJSON; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY3JlYXRlLXByb2plY3QudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGNoYWxrIGZyb20gJ2NoYWxrJ1xuaW1wb3J0IGRlZ2l0IGZyb20gJ2RlZ2l0J1xuaW1wb3J0IGV4ZWNhIGZyb20gJ2V4ZWNhJ1xuaW1wb3J0IGZzZSBmcm9tICdmcy1leHRyYSdcbmltcG9ydCBvcmEgZnJvbSAnb3JhJ1xuaW1wb3J0IHBhdGggZnJvbSAncGF0aCdcblxuaW1wb3J0IHR5cGUgeyBDbGlBcmdzLCBEYkRldGFpbHMsIFBhY2thZ2VNYW5hZ2VyLCBQcm9qZWN0VGVtcGxhdGUgfSBmcm9tICcuLi90eXBlcydcblxuaW1wb3J0IHsgZXJyb3IsIHN1Y2Nlc3MsIHdhcm5pbmcgfSBmcm9tICcuLi91dGlscy9sb2cnXG5pbXBvcnQgeyB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SxHQUFHeEI7UUFDbEIsTUFBTWhCLGdCQUFHLENBQUN5QyxTQUFTLENBQUNKLGlCQUFpQkMsWUFBWTtZQUFFSSxRQUFRO1FBQUU7SUFDL0QsRUFBRSxPQUFPOUIsS0FBYztRQUNyQitCLElBQUFBLFlBQU8sRUFBQztJQUNWO0FBQ0YifQ== |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var fs_extra_1 = __importDefault(require("fs-extra")); | ||
var path_1 = __importDefault(require("path")); | ||
var create_project_1 = require("./create-project"); | ||
var packages_1 = require("./packages"); | ||
var projectDir = path_1.default.resolve(__dirname, './tmp'); | ||
describe('createProject', function () { | ||
beforeAll(function () { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _createproject = require("./create-project"); | ||
const _packages = require("./packages"); | ||
const _templates = require("./templates"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
const projectDir = _path.default.resolve(__dirname, './tmp'); | ||
describe('createProject', ()=>{ | ||
beforeAll(()=>{ | ||
console.log = jest.fn(); | ||
}); | ||
beforeEach(function () { | ||
if (fs_extra_1.default.existsSync(projectDir)) { | ||
fs_extra_1.default.rmdirSync(projectDir, { recursive: true }); | ||
beforeEach(()=>{ | ||
if (_fsextra.default.existsSync(projectDir)) { | ||
_fsextra.default.rmdirSync(projectDir, { | ||
recursive: true | ||
}); | ||
} | ||
}); | ||
afterEach(function () { | ||
if (fs_extra_1.default.existsSync(projectDir)) { | ||
fs_extra_1.default.rmdirSync(projectDir, { recursive: true }); | ||
afterEach(()=>{ | ||
if (_fsextra.default.existsSync(projectDir)) { | ||
_fsextra.default.rmSync(projectDir, { | ||
recursive: true | ||
}); | ||
} | ||
}); | ||
describe('#createProject', function () { | ||
describe('#createProject', ()=>{ | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
var args = { | ||
_: ['project-name'], | ||
const args = { | ||
_: [ | ||
'project-name' | ||
], | ||
'--db': 'mongodb', | ||
'--no-deps': true, | ||
'--no-deps': true | ||
}; | ||
var packageManager = 'yarn'; | ||
it('creates starter project', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var projectName, template, packageJsonPath, packageJson; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
projectName = 'starter-project'; | ||
template = { | ||
name: 'blank', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/payload/templates/blank', | ||
description: 'Blank Template', | ||
}; | ||
return [4 /*yield*/, (0, create_project_1.createProject)({ | ||
cliArgs: args, | ||
projectName: projectName, | ||
projectDir: projectDir, | ||
template: template, | ||
packageManager: packageManager, | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
packageJsonPath = path_1.default.resolve(projectDir, 'package.json'); | ||
packageJson = fs_extra_1.default.readJsonSync(packageJsonPath); | ||
// Check package name and description | ||
expect(packageJson.name).toEqual(projectName); | ||
return [2 /*return*/]; | ||
} | ||
const packageManager = 'yarn'; | ||
it('creates starter project', async ()=>{ | ||
const projectName = 'starter-project'; | ||
const template = { | ||
name: 'blank', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/payload/templates/blank', | ||
description: 'Blank Template' | ||
}; | ||
await (0, _createproject.createProject)({ | ||
cliArgs: args, | ||
projectName, | ||
projectDir, | ||
template, | ||
packageManager | ||
}); | ||
}); }); | ||
it('creates plugin template', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var projectName, template, packageJsonPath, packageJson; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
projectName = 'plugin'; | ||
template = { | ||
name: 'plugin', | ||
type: 'plugin', | ||
url: 'https://github.com/payloadcms/payload-plugin-template', | ||
description: 'Template for creating a Payload plugin', | ||
}; | ||
return [4 /*yield*/, (0, create_project_1.createProject)({ | ||
cliArgs: args, | ||
projectName: projectName, | ||
projectDir: projectDir, | ||
template: template, | ||
packageManager: packageManager, | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
packageJsonPath = path_1.default.resolve(projectDir, 'package.json'); | ||
packageJson = fs_extra_1.default.readJsonSync(packageJsonPath); | ||
// Check package name and description | ||
expect(packageJson.name).toEqual(projectName); | ||
return [2 /*return*/]; | ||
} | ||
const packageJsonPath = _path.default.resolve(projectDir, 'package.json'); | ||
const packageJson = _fsextra.default.readJsonSync(packageJsonPath); | ||
// Check package name and description | ||
expect(packageJson.name).toEqual(projectName); | ||
}); | ||
it('creates plugin template', async ()=>{ | ||
const projectName = 'plugin'; | ||
const template = { | ||
name: 'plugin', | ||
type: 'plugin', | ||
url: 'https://github.com/payloadcms/payload-plugin-template', | ||
description: 'Template for creating a Payload plugin' | ||
}; | ||
await (0, _createproject.createProject)({ | ||
cliArgs: args, | ||
projectName, | ||
projectDir, | ||
template, | ||
packageManager | ||
}); | ||
}); }); | ||
describe('db adapters and bundlers', function () { | ||
const packageJsonPath = _path.default.resolve(projectDir, 'package.json'); | ||
const packageJson = _fsextra.default.readJsonSync(packageJsonPath); | ||
// Check package name and description | ||
expect(packageJson.name).toEqual(projectName); | ||
}); | ||
describe('db adapters and bundlers', ()=>{ | ||
const templates = (0, _templates.getValidTemplates)(); | ||
it.each([ | ||
['mongodb', 'webpack'], | ||
['postgres', 'webpack'], | ||
])('update config and deps: %s, %s', function (db, bundler) { return __awaiter(void 0, void 0, void 0, function () { | ||
var projectName, template, dbReplacement, bundlerReplacement, editorReplacement, packageJsonPath, packageJson, payloadConfigPath, content; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
projectName = 'starter-project'; | ||
template = { | ||
name: 'blank', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/payload/templates/blank', | ||
description: 'Blank Template', | ||
}; | ||
return [4 /*yield*/, (0, create_project_1.createProject)({ | ||
cliArgs: args, | ||
projectName: projectName, | ||
projectDir: projectDir, | ||
template: template, | ||
packageManager: packageManager, | ||
dbDetails: { | ||
dbUri: "".concat(db, "://localhost:27017/create-project-test"), | ||
type: db, | ||
}, | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
dbReplacement = packages_1.dbPackages[db]; | ||
bundlerReplacement = packages_1.bundlerPackages[bundler]; | ||
editorReplacement = packages_1.editorPackages['slate']; | ||
packageJsonPath = path_1.default.resolve(projectDir, 'package.json'); | ||
packageJson = fs_extra_1.default.readJsonSync(packageJsonPath); | ||
// Check deps | ||
expect(packageJson.dependencies['payload']).toEqual('^2.0.0'); | ||
expect(packageJson.dependencies[dbReplacement.packageName]).toEqual(dbReplacement.version); | ||
// Should only have one db adapter | ||
expect(Object.keys(packageJson.dependencies).filter(function (n) { | ||
return n.startsWith('@payloadcms/db-'); | ||
})).toHaveLength(1); | ||
expect(packageJson.dependencies[bundlerReplacement.packageName]).toEqual(bundlerReplacement.version); | ||
expect(packageJson.dependencies[editorReplacement.packageName]).toEqual(editorReplacement.version); | ||
payloadConfigPath = path_1.default.resolve(projectDir, 'src/payload.config.ts'); | ||
content = fs_extra_1.default.readFileSync(payloadConfigPath, 'utf-8'); | ||
// Check payload.config.ts | ||
expect(content).not.toContain('// database-adapter-import'); | ||
expect(content).toContain(dbReplacement.importReplacement); | ||
expect(content).not.toContain('// database-adapter-config-start'); | ||
expect(content).not.toContain('// database-adapter-config-end'); | ||
expect(content).toContain(dbReplacement.configReplacement.join('\n')); | ||
expect(content).not.toContain('// bundler-config-import'); | ||
expect(content).toContain(bundlerReplacement.importReplacement); | ||
expect(content).not.toContain('// bundler-config'); | ||
expect(content).toContain(bundlerReplacement.configReplacement); | ||
return [2 /*return*/]; | ||
[ | ||
'blank', | ||
'mongodb', | ||
'webpack' | ||
], | ||
[ | ||
'blank', | ||
'postgres', | ||
'webpack' | ||
], | ||
[ | ||
'website', | ||
'mongodb', | ||
'webpack' | ||
], | ||
[ | ||
'website', | ||
'postgres', | ||
'webpack' | ||
], | ||
[ | ||
'ecommerce', | ||
'mongodb', | ||
'webpack' | ||
], | ||
[ | ||
'ecommerce', | ||
'postgres', | ||
'webpack' | ||
] | ||
])('update config and deps: %s, %s, %s', async (templateName, db, bundler)=>{ | ||
const projectName = 'starter-project'; | ||
const template = templates.find((t)=>t.name === templateName); | ||
await (0, _createproject.createProject)({ | ||
cliArgs: args, | ||
projectName, | ||
projectDir, | ||
template, | ||
packageManager, | ||
dbDetails: { | ||
dbUri: `${db}://localhost:27017/create-project-test`, | ||
type: db | ||
} | ||
}); | ||
}); }); | ||
const dbReplacement = _packages.dbPackages[db]; | ||
const bundlerReplacement = _packages.bundlerPackages[bundler]; | ||
const editorReplacement = _packages.editorPackages['slate']; | ||
const packageJsonPath = _path.default.resolve(projectDir, 'package.json'); | ||
const packageJson = _fsextra.default.readJsonSync(packageJsonPath); | ||
// Check deps | ||
expect(packageJson.dependencies['payload']).toEqual('^2.0.0'); | ||
expect(packageJson.dependencies[dbReplacement.packageName]).toEqual(dbReplacement.version); | ||
// Should only have one db adapter | ||
expect(Object.keys(packageJson.dependencies).filter((n)=>n.startsWith('@payloadcms/db-'))).toHaveLength(1); | ||
expect(packageJson.dependencies[bundlerReplacement.packageName]).toEqual(bundlerReplacement.version); | ||
expect(packageJson.dependencies[editorReplacement.packageName]).toEqual(editorReplacement.version); | ||
let payloadConfigPath = _path.default.resolve(projectDir, 'src/payload.config.ts'); | ||
// Website and ecommerce templates have payload.config.ts in src/payload | ||
if (!_fsextra.default.existsSync(payloadConfigPath)) { | ||
payloadConfigPath = _path.default.resolve(projectDir, 'src/payload/payload.config.ts'); | ||
} | ||
const content = _fsextra.default.readFileSync(payloadConfigPath, 'utf-8'); | ||
// Check payload.config.ts | ||
expect(content).not.toContain('// database-adapter-import'); | ||
expect(content).toContain(dbReplacement.importReplacement); | ||
expect(content).not.toContain('// database-adapter-config-start'); | ||
expect(content).not.toContain('// database-adapter-config-end'); | ||
expect(content).toContain(dbReplacement.configReplacement.join('\n')); | ||
expect(content).not.toContain('// bundler-config-import'); | ||
expect(content).toContain(bundlerReplacement.importReplacement); | ||
expect(content).not.toContain('// bundler-config'); | ||
expect(content).toContain(bundlerReplacement.configReplacement); | ||
}); | ||
}); | ||
}); | ||
describe('Templates', function () { | ||
describe('Templates', ()=>{ | ||
it.todo('Verify that all templates are valid'); | ||
// Loop through all templates.ts that should have replacement comments, and verify that they are present | ||
// Loop through all templates.ts that should have replacement comments, and verify that they are present | ||
}); | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvY3JlYXRlLXByb2plY3Quc3BlYy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgZnNlIGZyb20gJ2ZzLWV4dHJhJ1xuaW1wb3J0IHBhdGggZnJvbSAncGF0aCdcbmltcG9ydCB0eXBlIHsgQnVuZGxlclR5cGUsIENsaUFyZ3MsIERiVHlwZSwgUHJvamVjdFRlbXBsYXRlIH0gZnJvbSAnLi4vdHlwZXMnXG5pbXBvcnQgeyBjcmVhdGVQcm9qZWN0IH0gZnJvbSAnLi9jcmVhdGUtcHJvamVjdCdcbmltcG9ydCB7IGJ1bmRsZXJQYWNrYWdlcywgZGJQYWNrYWdlcywgZWRpdG9yUGFja2FnZXMgfSBmcm9tICcuL3BhY2thZ2VzJ1xuaW1wb3J0IGV4cCBmcm9tICdjb25zdGFudHMnXG5pbXBvcnQgeyBnZXRWYWxpZFRlbXBsYXRlcyB9IGZyb20gJy4vdGVtcGxhdGVzJ1xuXG5jb25zdCBwcm9qZWN0RGlyID0gcGF0aC5yZXNvbHZlKF9fZGlybmFtZSwgJ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AgIHBheWxvYWRDb25maWdQYXRoID0gcGF0aC5yZXNvbHZlKHByb2plY3REaXIsICdzcmMvcGF5bG9hZC9wYXlsb2FkLmNvbmZpZy50cycpXG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgY29udGVudCA9IGZzZS5yZWFkRmlsZVN5bmMocGF5bG9hZENvbmZpZ1BhdGgsICd1dGYtOCcpXG5cbiAgICAgICAgLy8gQ2hlY2sgcGF5bG9hZC5jb25maWcudHNcbiAgICAgICAgZXhwZWN0KGNvbnRlbnQpLm5vdC50b0NvbnRhaW4oJy8vIGRhdGFiYXNlLWFkYXB0ZXItaW1wb3J0JylcbiAgICAgICAgZXhwZWN0KGNvbnRlbnQpLnRvQ29udGFpbihkYlJlcGxhY2VtZW50LmltcG9ydFJlcGxhY2VtZW50KVxuXG4gICAgICAgIGV4cGVjdChjb250ZW50KS5ub3QudG9Db250YWluKCcvLyBkYXRhYmFzZS1hZGFwdGVyLWNvbmZpZy1zdGFydCcpXG4gICAgICAgIGV4cGVjdChjb250ZW50KS5ub3QudG9Db250YWluKCcvLyBkYXRhYmFzZS1hZGFwdGVyLWNvbmZpZy1lbmQnKVxuICAgICAgICBleHBlY3QoY29udGVudCkudG9Db250YWluKGRiUmVwbGFjZW1lbnQuY29uZmlnUmVwbGFjZW1lbnQuam9pbignXFxuJykpXG5cbiAgICAgICAgZXhwZWN0KGNvbnRlbnQpLm5vdC50b0NvbnRhaW4oJy8vIGJ1bmRsZXItY29uZmlnLWltcG9ydCcpXG4gICAgICAgIGV4cGVjdChjb250ZW50KS50b0NvbnRhaW4oYnVuZGxlclJlcGxhY2VtZW50LmltcG9ydFJlcGxhY2VtZW50KVxuXG4gICAgICAgIGV4cGVjdChjb250ZW50KS5ub3QudG9Db250YWluKCcvLyBidW5kbGVyLWNvbmZpZycpXG4gICAgICAgIGV4cGVjdChjb250ZW50KS50b0NvbnRhaW4oYnVuZGxlclJlcGxhY2VtZW50LmNvbmZpZ1JlcGxhY2VtZW50KVxuICA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FtQmtCLGlCQUFpQjtnQkFFOURoQyxPQUFPNEIsU0FBU0UsR0FBRyxDQUFDQyxTQUFTLENBQUM7Z0JBQzlCL0IsT0FBTzRCLFNBQVNHLFNBQVMsQ0FBQ2pCLG1CQUFtQm1CLGlCQUFpQjtZQUNoRTtRQUNGO0lBQ0Y7SUFFQTdELFNBQVMsYUFBYTtRQUNwQmdCLEdBQUcrQyxJQUFJLENBQUM7SUFDUix3R0FBd0c7SUFDMUc7QUFDRiJ9 |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "generateSecret", { | ||
enumerable: true, | ||
get: function() { | ||
return generateSecret; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateSecret = void 0; | ||
var crypto_1 = require("crypto"); | ||
}); | ||
const _crypto = require("crypto"); | ||
function generateSecret() { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (0, crypto_1.randomBytes)(32).toString('hex').slice(0, 24)]; | ||
}); | ||
}); | ||
return (0, _crypto.randomBytes)(32).toString('hex').slice(0, 24); | ||
} | ||
exports.generateSecret = generateSecret; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvZ2VuZXJhdGUtc2VjcmV0LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IHJhbmRvbUJ5dGVzIH0gZnJvbSAnY3J5cHRvJ1xuXG5leHBvcnQgZnVuY3Rpb24gZ2VuZXJhdGVTZWNyZXQoKTogc3RyaW5nIHtcbiAgcmV0dXJuIHJhbmRvbUJ5dGVzKDMyKS50b1N0cmluZygnaGV4Jykuc2xpY2UoMCwgMjQpXG59XG4iXSwibmFtZXMiOlsiZ2VuZXJhdGVTZWNyZXQiLCJyYW5kb21CeXRlcyIsInRvU3RyaW5nIiwic2xpY2UiXSwibWFwcGluZ3MiOiI7Ozs7K0JBRWdCQTs7O2VBQUFBOzs7d0JBRlk7QUFFckIsU0FBU0E7SUFDZCxPQUFPQyxJQUFBQSxtQkFBVyxFQUFDLElBQUlDLFFBQVEsQ0FBQyxPQUFPQyxLQUFLLENBQUMsR0FBRztBQUNsRCJ9 |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.editorPackages = exports.bundlerPackages = exports.dbPackages = void 0; | ||
var mongodbReplacement = { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
dbPackages: function() { | ||
return dbPackages; | ||
}, | ||
bundlerPackages: function() { | ||
return bundlerPackages; | ||
}, | ||
editorPackages: function() { | ||
return editorPackages; | ||
} | ||
}); | ||
const mongodbReplacement = { | ||
importReplacement: "import { mongooseAdapter } from '@payloadcms/db-mongodb'", | ||
packageName: '@payloadcms/db-mongodb', | ||
importReplacement: "import { mongooseAdapter } from '@payloadcms/db-mongodb'", | ||
// Replacement between `// database-adapter-config-start` and `// database-adapter-config-end` | ||
@@ -11,9 +29,7 @@ configReplacement: [ | ||
' url: process.env.DATABASE_URI,', | ||
' }),', | ||
' }),' | ||
], | ||
version: '^1.0.0', | ||
version: '^1.0.0' | ||
}; | ||
var postgresReplacement = { | ||
packageName: '@payloadcms/db-postgres', | ||
importReplacement: "import { postgresAdapter } from '@payloadcms/db-postgres'", | ||
const postgresReplacement = { | ||
configReplacement: [ | ||
@@ -24,40 +40,44 @@ ' db: postgresAdapter({', | ||
' },', | ||
' }),', | ||
' }),' | ||
], | ||
version: '^0.x', // up to, not including 1.0.0 | ||
importReplacement: "import { postgresAdapter } from '@payloadcms/db-postgres'", | ||
packageName: '@payloadcms/db-postgres', | ||
version: '^0.x' | ||
}; | ||
exports.dbPackages = { | ||
const dbPackages = { | ||
mongodb: mongodbReplacement, | ||
postgres: postgresReplacement, | ||
postgres: postgresReplacement | ||
}; | ||
var webpackReplacement = { | ||
const webpackReplacement = { | ||
importReplacement: "import { webpackBundler } from '@payloadcms/bundler-webpack'", | ||
packageName: '@payloadcms/bundler-webpack', | ||
importReplacement: "import { webpackBundler } from '@payloadcms/bundler-webpack'", | ||
// Replacement of line containing `// bundler-config` | ||
configReplacement: ' bundler: webpackBundler(),', | ||
version: '^1.0.0', | ||
version: '^1.0.0' | ||
}; | ||
var viteReplacement = { | ||
const viteReplacement = { | ||
configReplacement: ' bundler: viteBundler(),', | ||
importReplacement: "import { viteBundler } from '@payloadcms/bundler-vite'", | ||
packageName: '@payloadcms/bundler-vite', | ||
importReplacement: "import { viteBundler } from '@payloadcms/bundler-vite'", | ||
configReplacement: ' bundler: viteBundler(),', | ||
version: '^0.x', // up to, not including 1.0.0 | ||
version: '^0.x' | ||
}; | ||
exports.bundlerPackages = { | ||
webpack: webpackReplacement, | ||
const bundlerPackages = { | ||
vite: viteReplacement, | ||
webpack: webpackReplacement | ||
}; | ||
exports.editorPackages = { | ||
slate: { | ||
packageName: '@payloadcms/richtext-slate', | ||
importReplacement: "import { slateEditor } from '@payloadcms/richtext-slate'", | ||
configReplacement: ' editor: slateEditor({}),', | ||
version: '^1.0.0', | ||
}, | ||
const editorPackages = { | ||
lexical: { | ||
configReplacement: ' editor: lexicalEditor({}),', | ||
importReplacement: "import { lexicalEditor } from '@payloadcms/richtext-lexical'", | ||
packageName: '@payloadcms/richtext-lexical', | ||
importReplacement: "import { lexicalEditor } from '@payloadcms/richtext-lexical'", | ||
configReplacement: ' editor: lexicalEditor({}),', | ||
version: '^0.x', // up to, not including 1.0.0 | ||
version: '^0.x' | ||
}, | ||
slate: { | ||
configReplacement: ' editor: slateEditor({}),', | ||
importReplacement: "import { slateEditor } from '@payloadcms/richtext-slate'", | ||
packageName: '@payloadcms/richtext-slate', | ||
version: '^1.0.0' | ||
} | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvcGFja2FnZXMudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBCdW5kbGVyVHlwZSwgRGJUeXBlLCBFZGl0b3JUeXBlIH0gZnJvbSAnLi4vdHlwZXMnXG5cbnR5cGUgRGJBZGFwdGVyUmVwbGFjZW1lbnQgPSB7XG4gIGNvbmZpZ1JlcGxhY2VtZW50OiBzdHJpbmdbXVxuICBpbXBvcnRSZXBsYWNlbWVudDogc3RyaW5nXG4gIHBhY2thZ2VOYW1lOiBzdHJpbmdcbiAgdmVyc2lvbjogc3RyaW5nXG59XG5cbnR5cGUgQnVuZGxlclJlcGxhY2VtZW50ID0ge1xuICBjb25maWdSZXBsYWNlbWVudDogc3RyaW5nXG4gIGltcG9ydFJlcGxhY2VtZW50OiBzdHJpbmdcbiAgcGFja2FnZU5hbWU6IHN0cmluZ1xuICB2ZXJzaW9uOiBzdHJpbmdcbn1cblxudHlwZSBFZGl0b3JSZXBsYWNlbWVudCA9IHtcbiAgY29uZmlnUmVwbGFjZW1lbnQ6IHN0cmluZ1xuICBpbXBvcnRSZXBsYWNlbWVudDogc3RyaW5nXG4gIHBhY2thZ2VOYW1lOiBzdHJpbmdcbiAgdmVyc2lvbjogc3RyaW5nXG59XG5cbmNvbnN0IG1vbmdvZGJSZXBsYWNlbWVudDogRGJBZGFwdGVyUmVwbGFjZW1lbnQgPSB7XG4gIGltcG9ydFJlcGxhY2VtZW50OiBcImltcG9ydCB7IG1vbmdvb3NlQWRhcHRlciB9IGZyb20gJ0BwYXlsb2FkY21zL2RiLW1vbmdvZGInXCIsXG4gIHBhY2thZ2VOYW1lOiAnQHBheWxvYWRjbXMvZGItbW9uZ29kYicsXG4gIC8vIFJlcGxhY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7ZUFBZEE7OztBQTlDYixNQUFNQyxxQkFBMkM7SUFDL0NDLG1CQUFtQjtJQUNuQkMsYUFBYTtJQUNiLDhGQUE4RjtJQUM5RkMsbUJBQW1CO1FBQUM7UUFBMkI7UUFBc0M7S0FBUTtJQUM3RkMsU0FBUztBQUNYO0FBRUEsTUFBTUMsc0JBQTRDO0lBQ2hERixtQkFBbUI7UUFDakI7UUFDQTtRQUNBO1FBQ0E7UUFDQTtLQUNEO0lBQ0RGLG1CQUFtQjtJQUNuQkMsYUFBYTtJQUNiRSxTQUFTO0FBQ1g7QUFFTyxNQUFNUCxhQUFtRDtJQUM5RFMsU0FBU047SUFDVE8sVUFBVUY7QUFDWjtBQUVBLE1BQU1HLHFCQUF5QztJQUM3Q1AsbUJBQW1CO0lBQ25CQyxhQUFhO0lBQ2IscURBQXFEO0lBQ3JEQyxtQkFBbUI7SUFDbkJDLFNBQVM7QUFDWDtBQUVBLE1BQU1LLGtCQUFzQztJQUMxQ04sbUJBQW1CO0lBQ25CRixtQkFBbUI7SUFDbkJDLGFBQWE7SUFDYkUsU0FBUztBQUNYO0FBRU8sTUFBTU4sa0JBQTJEO0lBQ3RFWSxNQUFNRDtJQUNORSxTQUFTSDtBQUNYO0FBRU8sTUFBTVQsaUJBQXdEO0lBQ25FYSxTQUFTO1FBQ1BULG1CQUFtQjtRQUNuQkYsbUJBQW1CO1FBQ25CQyxhQUFhO1FBQ2JFLFNBQVM7SUFDWDtJQUNBUyxPQUFPO1FBQ0xWLG1CQUFtQjtRQUNuQkYsbUJBQW1CO1FBQ25CQyxhQUFhO1FBQ2JFLFNBQVM7SUFDWDtBQUNGIn0= |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "parseProjectName", { | ||
enumerable: true, | ||
get: function() { | ||
return parseProjectName; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseProjectName = void 0; | ||
var prompts_1 = __importDefault(require("prompts")); | ||
function parseProjectName(args) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (args['--name']) | ||
return [2 /*return*/, args['--name']]; | ||
if (args._[0]) | ||
return [2 /*return*/, args._[0]]; | ||
return [4 /*yield*/, (0, prompts_1.default)({ | ||
type: 'text', | ||
name: 'value', | ||
message: 'Project name?', | ||
validate: function (value) { return !!value.length; }, | ||
}, { | ||
onCancel: function () { | ||
process.exit(0); | ||
}, | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
return [2 /*return*/, response.value]; | ||
} | ||
}); | ||
}); | ||
const _prompts = /*#__PURE__*/ _interop_require_default(require("prompts")); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
async function parseProjectName(args) { | ||
if (args['--name']) return args['--name']; | ||
if (args._[0]) return args._[0]; | ||
const response = await (0, _prompts.default)({ | ||
name: 'value', | ||
message: 'Project name?', | ||
type: 'text', | ||
validate: (value)=>!!value.length | ||
}, { | ||
onCancel: ()=>{ | ||
process.exit(0); | ||
} | ||
}); | ||
return response.value; | ||
} | ||
exports.parseProjectName = parseProjectName; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvcGFyc2UtcHJvamVjdC1uYW1lLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBwcm9tcHRzIGZyb20gJ3Byb21wdHMnXG5cbmltcG9ydCB0eXBlIHsgQ2xpQXJncyB9IGZyb20gJy4uL3R5cGVzJ1xuXG5leHBvcn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yxJQUFBQSxnQkFBTyxFQUM1QjtRQUNFQyxNQUFNO1FBQ05DLFNBQVM7UUFDVEMsTUFBTTtRQUNOQyxVQUFVLENBQUNDLFFBQWtCLENBQUMsQ0FBQ0EsTUFBTUMsTUFBTTtJQUM3QyxHQUNBO1FBQ0VDLFVBQVU7WUFDUkMsUUFBUUMsSUFBSSxDQUFDO1FBQ2Y7SUFDRjtJQUdGLE9BQU9WLFNBQVNNLEtBQUs7QUFDdkIifQ== |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "parseTemplate", { | ||
enumerable: true, | ||
get: function() { | ||
return parseTemplate; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseTemplate = void 0; | ||
var prompts_1 = __importDefault(require("prompts")); | ||
function parseTemplate(args, validTemplates) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var templateName_1, template_1, response, template; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (args['--template']) { | ||
templateName_1 = args['--template']; | ||
template_1 = validTemplates.find(function (t) { return t.name === templateName_1; }); | ||
if (!template_1) | ||
throw new Error('Invalid template given'); | ||
return [2 /*return*/, template_1]; | ||
} | ||
return [4 /*yield*/, (0, prompts_1.default)({ | ||
type: 'select', | ||
name: 'value', | ||
message: 'Choose project template', | ||
choices: validTemplates.map(function (p) { | ||
return { | ||
title: p.name, | ||
value: p.name, | ||
description: p.description, | ||
}; | ||
}), | ||
validate: function (value) { return !!value.length; }, | ||
}, { | ||
onCancel: function () { | ||
process.exit(0); | ||
}, | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
template = validTemplates.find(function (t) { return t.name === response.value; }); | ||
if (!template) | ||
throw new Error('Template is undefined'); | ||
return [2 /*return*/, template]; | ||
} | ||
}); | ||
}); | ||
const _prompts = /*#__PURE__*/ _interop_require_default(require("prompts")); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
async function parseTemplate(args, validTemplates) { | ||
if (args['--template']) { | ||
const templateName = args['--template']; | ||
const template = validTemplates.find((t)=>t.name === templateName); | ||
if (!template) throw new Error('Invalid template given'); | ||
return template; | ||
} | ||
const response = await (0, _prompts.default)({ | ||
name: 'value', | ||
choices: validTemplates.map((p)=>{ | ||
return { | ||
description: p.description, | ||
title: p.name, | ||
value: p.name | ||
}; | ||
}), | ||
message: 'Choose project template', | ||
type: 'select', | ||
validate: (value)=>!!value.length | ||
}, { | ||
onCancel: ()=>{ | ||
process.exit(0); | ||
} | ||
}); | ||
const template = validTemplates.find((t)=>t.name === response.value); | ||
if (!template) throw new Error('Template is undefined'); | ||
return template; | ||
} | ||
exports.parseTemplate = parseTemplate; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvcGFyc2UtdGVtcGxhdGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHByb21wdHMgZnJvbSAncHJvbXB0cydcblxuaW1wb3J0IHR5cGUgeyBDbGlBcmdzLCBQcm9qZWN0VGVtcGxhdGUgfSBmcm9tICcuLi90eXBlcydcblxuZXhwb3J0IGFzeW5jIGZ1bmN0aW9uIHBhcnNlVGVtcGxhdGUoXG4gIGFyZ3M6IENsaUFyZ3MsXG4gIHZhbGlkVGVtcGxhdGVzOiBQcm9qZWN0VGVtcGxhdGVbXSxcbik6IFByb21pc2U8UHJvamVjdFRlbXBsYXRlPiB7XG4gIGlmIChhcmdzWyctLXRlbXBsYXRlJ10pIHtcbiAgICBjb25zdCB0ZW1wbGF0ZU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LFdBQVdGLGVBQWVHLElBQUksQ0FBQyxDQUFDQyxJQUFNQSxFQUFFQyxJQUFJLEtBQUtFLFNBQVNPLEtBQUs7SUFDckUsSUFBSSxDQUFDWixVQUFVLE1BQU0sSUFBSUksTUFBTTtJQUUvQixPQUFPSjtBQUNUIn0= |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "selectDb", { | ||
enumerable: true, | ||
get: function() { | ||
return selectDb; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.selectDb = void 0; | ||
var prompts_1 = __importDefault(require("prompts")); | ||
var slugify_1 = __importDefault(require("@sindresorhus/slugify")); | ||
var dbChoiceRecord = { | ||
}); | ||
const _slugify = /*#__PURE__*/ _interop_require_default(require("@sindresorhus/slugify")); | ||
const _prompts = /*#__PURE__*/ _interop_require_default(require("prompts")); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
const dbChoiceRecord = { | ||
mongodb: { | ||
value: 'mongodb', | ||
dbConnectionPrefix: 'mongodb://127.0.0.1/', | ||
title: 'MongoDB', | ||
dbConnectionPrefix: 'mongodb://127.0.0.1/', | ||
value: 'mongodb' | ||
}, | ||
postgres: { | ||
value: 'postgres', | ||
dbConnectionPrefix: 'postgres://127.0.0.1:5432/', | ||
title: 'PostgreSQL (beta)', | ||
dbConnectionPrefix: 'postgres://127.0.0.1:5432/', | ||
}, | ||
value: 'postgres' | ||
} | ||
}; | ||
function selectDb(args, projectName) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var dbType, dbTypeRes, dbChoice, dbUriRes; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
dbType = undefined; | ||
if (!args['--db']) return [3 /*break*/, 1]; | ||
if (!Object.values(dbChoiceRecord).some(function (dbChoice) { return dbChoice.value === args['--db']; })) { | ||
throw new Error("Invalid database type given. Valid types are: ".concat(Object.values(dbChoiceRecord) | ||
.map(function (dbChoice) { return dbChoice.value; }) | ||
.join(', '))); | ||
} | ||
dbType = args['--db']; | ||
return [3 /*break*/, 3]; | ||
case 1: return [4 /*yield*/, (0, prompts_1.default)({ | ||
type: 'select', | ||
name: 'value', | ||
message: 'Select a database', | ||
choices: Object.values(dbChoiceRecord).map(function (dbChoice) { | ||
return { | ||
title: dbChoice.title, | ||
value: dbChoice.value, | ||
}; | ||
}), | ||
validate: function (value) { return !!value.length; }, | ||
}, { | ||
onCancel: function () { | ||
process.exit(0); | ||
}, | ||
})]; | ||
case 2: | ||
dbTypeRes = _a.sent(); | ||
dbType = dbTypeRes.value; | ||
_a.label = 3; | ||
case 3: | ||
dbChoice = dbChoiceRecord[dbType]; | ||
return [4 /*yield*/, (0, prompts_1.default)({ | ||
type: 'text', | ||
name: 'value', | ||
message: "Enter ".concat(dbChoice.title.split(' ')[0], " connection string"), | ||
initial: "".concat(dbChoice.dbConnectionPrefix).concat(projectName === '.' | ||
? "payload-".concat(getRandomDigitSuffix()) | ||
: (0, slugify_1.default)(projectName)), | ||
validate: function (value) { return !!value.length; }, | ||
}, { | ||
onCancel: function () { | ||
process.exit(0); | ||
}, | ||
})]; | ||
case 4: | ||
dbUriRes = _a.sent(); | ||
return [2 /*return*/, { | ||
type: dbChoice.value, | ||
dbUri: dbUriRes.value, | ||
}]; | ||
async function selectDb(args, projectName) { | ||
let dbType = undefined; | ||
if (args['--db']) { | ||
if (!Object.values(dbChoiceRecord).some((dbChoice)=>dbChoice.value === args['--db'])) { | ||
throw new Error(`Invalid database type given. Valid types are: ${Object.values(dbChoiceRecord).map((dbChoice)=>dbChoice.value).join(', ')}`); | ||
} | ||
dbType = args['--db']; | ||
} else { | ||
const dbTypeRes = await (0, _prompts.default)({ | ||
name: 'value', | ||
choices: Object.values(dbChoiceRecord).map((dbChoice)=>{ | ||
return { | ||
title: dbChoice.title, | ||
value: dbChoice.value | ||
}; | ||
}), | ||
message: 'Select a database', | ||
type: 'select', | ||
validate: (value)=>!!value.length | ||
}, { | ||
onCancel: ()=>{ | ||
process.exit(0); | ||
} | ||
}); | ||
dbType = dbTypeRes.value; | ||
} | ||
const dbChoice = dbChoiceRecord[dbType]; | ||
const dbUriRes = await (0, _prompts.default)({ | ||
name: 'value', | ||
initial: `${dbChoice.dbConnectionPrefix}${projectName === '.' ? `payload-${getRandomDigitSuffix()}` : (0, _slugify.default)(projectName)}`, | ||
message: `Enter ${dbChoice.title.split(' ')[0]} connection string`, | ||
type: 'text', | ||
validate: (value)=>!!value.length | ||
}, { | ||
onCancel: ()=>{ | ||
process.exit(0); | ||
} | ||
}); | ||
return { | ||
dbUri: dbUriRes.value, | ||
type: dbChoice.value | ||
}; | ||
} | ||
exports.selectDb = selectDb; | ||
function getRandomDigitSuffix() { | ||
return (Math.random() * Math.pow(10, 6)).toFixed(0); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvc2VsZWN0LWRiLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBzbHVnaWZ5IGZyb20gJ0BzaW5kcmVzb3JodXMvc2x1Z2lmeSdcbmltcG9ydCBwcm9tcHRzIGZyb20gJ3Byb21wdHMnXG5cbmltcG9ydCB0eXBlIHsgQ2xpQXJncywgRGJEZXRhaWxzLCBEYlR5cGUgfSBmcm9tICcuLi90eXBlcydcblxudHlwZSBEYkNob2ljZSA9IHtcbiAgZGJDb25uZWN0aW9uUHJlZml4OiBgJHtzdHJpbmd9L2BcbiAgdGl0bGU6IHN0cmluZ1xuICB2YWx1ZTogRGJUeXBlXG59XG5cbmNvbnN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HQUNBO1lBQ0VDLFVBQVU7Z0JBQ1JDLFFBQVFDLElBQUksQ0FBQztZQUNmO1FBQ0Y7UUFFRm5CLFNBQVNTLFVBQVViLEtBQUs7SUFDMUI7SUFFQSxNQUFNUyxXQUFXYixjQUFjLENBQUNRLE9BQU87SUFFdkMsTUFBTW9CLFdBQVcsTUFBTVYsSUFBQUEsZ0JBQU8sRUFDNUI7UUFDRUMsTUFBTTtRQUNOVSxTQUFTLENBQUMsRUFBRWhCLFNBQVNYLGtCQUFrQixDQUFDLEVBQ3RDSyxnQkFBZ0IsTUFBTSxDQUFDLFFBQVEsRUFBRXVCLHVCQUF1QixDQUFDLEdBQUdDLElBQUFBLGdCQUFPLEVBQUN4QixhQUNyRSxDQUFDO1FBQ0ZjLFNBQVMsQ0FBQyxNQUFNLEVBQUVSLFNBQVNWLEtBQUssQ0FBQzZCLEtBQUssQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDLGtCQUFrQixDQUFDO1FBQ2xFVixNQUFNO1FBQ05DLFVBQVUsQ0FBQ25CLFFBQWtCLENBQUMsQ0FBQ0EsTUFBTW9CLE1BQU07SUFDN0MsR0FDQTtRQUNFQyxVQUFVO1lBQ1JDLFFBQVFDLElBQUksQ0FBQztRQUNmO0lBQ0Y7SUFHRixPQUFPO1FBQ0xNLE9BQU9MLFNBQVN4QixLQUFLO1FBQ3JCa0IsTUFBTVQsU0FBU1QsS0FBSztJQUN0QjtBQUNGO0FBRUEsU0FBUzBCO0lBQ1AsT0FBTyxBQUFDSSxDQUFBQSxLQUFLQyxNQUFNLEtBQUtELEtBQUtFLEdBQUcsQ0FBQyxJQUFJLEVBQUMsRUFBR0MsT0FBTyxDQUFDO0FBQ25EIn0= |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
}; | ||
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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
} | ||
_export(exports, { | ||
validateTemplate: function() { | ||
return validateTemplate; | ||
}, | ||
getValidTemplates: function() { | ||
return getValidTemplates; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getValidTemplates = exports.validateTemplate = void 0; | ||
var log_1 = require("../utils/log"); | ||
}); | ||
const _log = require("../utils/log"); | ||
function validateTemplate(templateName) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var validTemplates; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, getValidTemplates()]; | ||
case 1: | ||
validTemplates = _a.sent(); | ||
if (!validTemplates.map(function (t) { return t.name; }).includes(templateName)) { | ||
(0, log_1.error)("'".concat(templateName, "' is not a valid template.")); | ||
(0, log_1.info)("Valid templates: ".concat(validTemplates.map(function (t) { return t.name; }).join(', '))); | ||
return [2 /*return*/, false]; | ||
} | ||
return [2 /*return*/, true]; | ||
} | ||
}); | ||
}); | ||
const validTemplates = getValidTemplates(); | ||
if (!validTemplates.map((t)=>t.name).includes(templateName)) { | ||
(0, _log.error)(`'${templateName}' is not a valid template.`); | ||
(0, _log.info)(`Valid templates: ${validTemplates.map((t)=>t.name).join(', ')}`); | ||
return false; | ||
} | ||
return true; | ||
} | ||
exports.validateTemplate = validateTemplate; | ||
function getValidTemplates() { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, [ | ||
{ | ||
name: 'blank', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/payload/templates/blank', | ||
description: 'Blank Template', | ||
}, | ||
{ | ||
name: 'website', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/payload/templates/website', | ||
description: 'Website Template', | ||
}, | ||
{ | ||
name: 'ecommerce', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/payload/templates/ecommerce', | ||
description: 'E-commerce Template', | ||
}, | ||
{ | ||
name: 'plugin', | ||
type: 'plugin', | ||
url: 'https://github.com/payloadcms/payload-plugin-template', | ||
description: 'Template for creating a Payload plugin', | ||
}, | ||
{ | ||
name: 'payload-demo', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/public-demo', | ||
description: 'Payload demo site at https://demo.payloadcms.com', | ||
}, | ||
{ | ||
name: 'payload-website', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/website-cms', | ||
description: 'Payload website CMS at https://payloadcms.com', | ||
}, | ||
]]; | ||
}); | ||
}); | ||
return [ | ||
{ | ||
name: 'blank', | ||
description: 'Blank Template', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/payload/templates/blank' | ||
}, | ||
{ | ||
name: 'website', | ||
description: 'Website Template', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/payload/templates/website' | ||
}, | ||
{ | ||
name: 'ecommerce', | ||
description: 'E-commerce Template', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/payload/templates/ecommerce' | ||
}, | ||
{ | ||
name: 'plugin', | ||
description: 'Template for creating a Payload plugin', | ||
type: 'plugin', | ||
url: 'https://github.com/payloadcms/payload-plugin-template' | ||
}, | ||
{ | ||
name: 'payload-demo', | ||
description: 'Payload demo site at https://demo.payloadcms.com', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/public-demo' | ||
}, | ||
{ | ||
name: 'payload-website', | ||
description: 'Payload website CMS at https://payloadcms.com', | ||
type: 'starter', | ||
url: 'https://github.com/payloadcms/website-cms' | ||
} | ||
]; | ||
} | ||
exports.getValidTemplates = getValidTemplates; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvdGVtcGxhdGVzLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgUHJvamVjdFRlbXBsYXRlIH0gZnJvbSAnLi4vdHlwZXMnXG5cbmltcG9ydCB7IG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FNO1lBQ05DLEtBQUs7UUFDUDtRQUNBO1lBQ0VQLE1BQU07WUFDTkssYUFBYTtZQUNiQyxNQUFNO1lBQ05DLEtBQUs7UUFDUDtLQUNEO0FBQ0gifQ== |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "writeEnvFile", { | ||
enumerable: true, | ||
get: function() { | ||
return writeEnvFile; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.writeEnvFile = void 0; | ||
var path_1 = __importDefault(require("path")); | ||
var fs_extra_1 = __importDefault(require("fs-extra")); | ||
var log_1 = require("../utils/log"); | ||
/** Parse and swap .env.example values and write .env */ | ||
function writeEnvFile(args) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var databaseUri, payloadSecret, template, projectDir, envFile, envWithValues, content, err_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
databaseUri = args.databaseUri, payloadSecret = args.payloadSecret, template = args.template, projectDir = args.projectDir; | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 7, , 8]); | ||
if (!(template.type === 'starter' && | ||
fs_extra_1.default.existsSync(path_1.default.join(projectDir, '.env.example')))) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, fs_extra_1.default.readFile(path_1.default.join(projectDir, '.env.example'), 'utf8')]; | ||
case 2: | ||
envFile = _a.sent(); | ||
envWithValues = envFile | ||
.split('\n') | ||
.filter(function (e) { return e; }) | ||
.map(function (line) { | ||
if (line.startsWith('#') || !line.includes('=')) | ||
return line; | ||
var split = line.split('='); | ||
var key = split[0]; | ||
var value = split[1]; | ||
if (key === 'MONGODB_URI' || | ||
key === 'MONGO_URL' || | ||
key === 'DATABASE_URI') { | ||
value = databaseUri; | ||
} | ||
if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') { | ||
value = payloadSecret; | ||
} | ||
return "".concat(key, "=").concat(value); | ||
}); | ||
// Write new .env file | ||
return [4 /*yield*/, fs_extra_1.default.writeFile(path_1.default.join(projectDir, '.env'), envWithValues.join('\n'))]; | ||
case 3: | ||
// Write new .env file | ||
_a.sent(); | ||
return [3 /*break*/, 6]; | ||
case 4: | ||
content = "MONGODB_URI=".concat(databaseUri, "\nPAYLOAD_SECRET=").concat(payloadSecret); | ||
return [4 /*yield*/, fs_extra_1.default.outputFile("".concat(projectDir, "/.env"), content)]; | ||
case 5: | ||
_a.sent(); | ||
_a.label = 6; | ||
case 6: | ||
(0, log_1.success)('.env file created'); | ||
return [3 /*break*/, 8]; | ||
case 7: | ||
err_1 = _a.sent(); | ||
(0, log_1.error)('Unable to write .env file'); | ||
if (err_1 instanceof Error) { | ||
(0, log_1.error)(err_1.message); | ||
} | ||
process.exit(1); | ||
return [3 /*break*/, 8]; | ||
case 8: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}); | ||
const _fsextra = /*#__PURE__*/ _interop_require_default(require("fs-extra")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _log = require("../utils/log"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
exports.writeEnvFile = writeEnvFile; | ||
async function writeEnvFile(args) { | ||
const { databaseUri, payloadSecret, projectDir, template } = args; | ||
try { | ||
if (template.type === 'starter' && _fsextra.default.existsSync(_path.default.join(projectDir, '.env.example'))) { | ||
// Parse .env file into key/value pairs | ||
const envFile = await _fsextra.default.readFile(_path.default.join(projectDir, '.env.example'), 'utf8'); | ||
const envWithValues = envFile.split('\n').filter((e)=>e).map((line)=>{ | ||
if (line.startsWith('#') || !line.includes('=')) return line; | ||
const split = line.split('='); | ||
const key = split[0]; | ||
let value = split[1]; | ||
if (key === 'MONGODB_URI' || key === 'MONGO_URL' || key === 'DATABASE_URI') { | ||
value = databaseUri; | ||
} | ||
if (key === 'PAYLOAD_SECRET' || key === 'PAYLOAD_SECRET_KEY') { | ||
value = payloadSecret; | ||
} | ||
return `${key}=${value}`; | ||
}); | ||
// Write new .env file | ||
await _fsextra.default.writeFile(_path.default.join(projectDir, '.env'), envWithValues.join('\n')); | ||
} else { | ||
const content = `MONGODB_URI=${databaseUri}\nPAYLOAD_SECRET=${payloadSecret}`; | ||
await _fsextra.default.outputFile(`${projectDir}/.env`, content); | ||
} | ||
(0, _log.success)('.env file created'); | ||
} catch (err) { | ||
(0, _log.error)('Unable to write .env file'); | ||
if (err instanceof Error) { | ||
(0, _log.error)(err.message); | ||
} | ||
process.exit(1); | ||
} | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvd3JpdGUtZW52LWZpbGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGZzIGZyb20gJ2ZzLWV4dHJhJ1xuaW1wb3J0IHBhdGggZnJvbSAncGF0aCdcblxuaW1wb3J0IHR5cGUgeyBQcm9qZWN0VGVtcGxhdGUgfSBmcm9tICcuLi90eXBlcydcblxuaW1wb3J0IHsgZXJyb3IsIHN1Y2Nlc3MgfSBmcm9tICcuLi91dGlscy9sb2cnXG5cbi8qKiBQYXJzZSBhbmQgc3dhcCAuZW52LmV4YW1wbGUgdmFsdWVzIGFuZCB3cml0ZSAuZW52ICovXG5leHBvcnQgYXN5bmMgZnVuY3Rpb24gd3JpdGVFbnZGaWxlKGFyZ3M6IHtcbiAgZGF0YWJhc2VVcmk6IHN0cmluZ1xuICBwYXlsb2FkU2VjcmV0OiBzdHJpbmdcbiAgcHJvamVjdERpcjogc3RyaW5nXG4gIHRlbXBsYXRlOiBQcm9qZWN0VGVtcGxhdG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tnQkFDQSxJQUFJbUIsUUFBUSxvQkFBb0JBLFFBQVEsc0JBQXNCO29CQUM1REMsUUFBUW5CO2dCQUNWO2dCQUVBLE9BQU8sQ0FBQyxFQUFFa0IsSUFBSSxDQUFDLEVBQUVDLE1BQU0sQ0FBQztZQUMxQjtZQUVGLHNCQUFzQjtZQUN0QixNQUFNZixnQkFBRSxDQUFDZ0IsU0FBUyxDQUFDZCxhQUFJLENBQUNDLElBQUksQ0FBQ04sWUFBWSxTQUFTUyxjQUFjSCxJQUFJLENBQUM7UUFDdkUsT0FBTztZQUNMLE1BQU1jLFVBQVUsQ0FBQyxZQUFZLEVBQUV0QixZQUFZLGlCQUFpQixFQUFFQyxjQUFjLENBQUM7WUFDN0UsTUFBTUksZ0JBQUUsQ0FBQ2tCLFVBQVUsQ0FBQyxDQUFDLEVBQUVyQixXQUFXLEtBQUssQ0FBQyxFQUFFb0I7UUFDNUM7UUFFQUUsSUFBQUEsWUFBTyxFQUFDO0lBQ1YsRUFBRSxPQUFPQyxLQUFjO1FBQ3JCQyxJQUFBQSxVQUFLLEVBQUM7UUFDTixJQUFJRCxlQUFlRSxPQUFPO1lBQ3hCRCxJQUFBQSxVQUFLLEVBQUNELElBQUlHLE9BQU87UUFDbkI7UUFDQUMsUUFBUUMsSUFBSSxDQUFDO0lBQ2Y7QUFDRiJ9 |
316
dist/main.js
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "Main", { | ||
enumerable: true, | ||
get: function() { | ||
return Main; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Main = void 0; | ||
var slugify_1 = __importDefault(require("@sindresorhus/slugify")); | ||
var arg_1 = __importDefault(require("arg")); | ||
var command_exists_1 = __importDefault(require("command-exists")); | ||
var create_project_1 = require("./lib/create-project"); | ||
var select_db_1 = require("./lib/select-db"); | ||
var generate_secret_1 = require("./lib/generate-secret"); | ||
var parse_project_name_1 = require("./lib/parse-project-name"); | ||
var parse_template_1 = require("./lib/parse-template"); | ||
var templates_1 = require("./lib/templates"); | ||
var write_env_file_1 = require("./lib/write-env-file"); | ||
var log_1 = require("./utils/log"); | ||
var messages_1 = require("./utils/messages"); | ||
var Main = /** @class */ (function () { | ||
function Main() { | ||
}); | ||
const _slugify = /*#__PURE__*/ _interop_require_default(require("@sindresorhus/slugify")); | ||
const _arg = /*#__PURE__*/ _interop_require_default(require("arg")); | ||
const _commandexists = /*#__PURE__*/ _interop_require_default(require("command-exists")); | ||
const _createproject = require("./lib/create-project"); | ||
const _generatesecret = require("./lib/generate-secret"); | ||
const _parseprojectname = require("./lib/parse-project-name"); | ||
const _parsetemplate = require("./lib/parse-template"); | ||
const _selectdb = require("./lib/select-db"); | ||
const _templates = require("./lib/templates"); | ||
const _writeenvfile = require("./lib/write-env-file"); | ||
const _log = require("./utils/log"); | ||
const _messages = require("./utils/messages"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
class Main { | ||
args; | ||
constructor(){ | ||
// @ts-expect-error bad typings | ||
this.args = (0, arg_1.default)({ | ||
this.args = (0, _arg.default)({ | ||
'--db': String, | ||
'--help': Boolean, | ||
'--name': String, | ||
'--secret': String, | ||
'--template': String, | ||
'--db': String, | ||
'--secret': String, | ||
// Package manager | ||
'--no-deps': Boolean, | ||
'--use-npm': Boolean, | ||
'--use-pnpm': Boolean, | ||
'--use-yarn': Boolean, | ||
'--use-pnpm': Boolean, | ||
'--no-deps': Boolean, | ||
// Flags | ||
'--beta': Boolean, | ||
'--dry-run': Boolean, | ||
'--beta': Boolean, | ||
// Aliases | ||
'-d': '--db', | ||
'-h': '--help', | ||
'-n': '--name', | ||
'-t': '--template', | ||
}, { permissive: true }); | ||
'-t': '--template' | ||
}, { | ||
permissive: true | ||
}); | ||
} | ||
Main.prototype.init = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _a, _b, templateArg, valid, _c, _d, projectName, validTemplates, template, projectDir, packageManager, dbDetails, payloadSecret, error_1; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
_e.trys.push([0, 18, , 19]); | ||
if (!this.args['--help']) return [3 /*break*/, 2]; | ||
_b = (_a = console).log; | ||
return [4 /*yield*/, (0, messages_1.helpMessage)()]; | ||
case 1: | ||
_b.apply(_a, [_e.sent()]); | ||
process.exit(0); | ||
_e.label = 2; | ||
case 2: | ||
templateArg = this.args['--template']; | ||
if (!templateArg) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, (0, templates_1.validateTemplate)(templateArg)]; | ||
case 3: | ||
valid = _e.sent(); | ||
if (!!valid) return [3 /*break*/, 5]; | ||
_d = (_c = console).log; | ||
return [4 /*yield*/, (0, messages_1.helpMessage)()]; | ||
case 4: | ||
_d.apply(_c, [_e.sent()]); | ||
process.exit(1); | ||
_e.label = 5; | ||
case 5: | ||
console.log(messages_1.welcomeMessage); | ||
return [4 /*yield*/, (0, parse_project_name_1.parseProjectName)(this.args)]; | ||
case 6: | ||
projectName = _e.sent(); | ||
return [4 /*yield*/, (0, templates_1.getValidTemplates)()]; | ||
case 7: | ||
validTemplates = _e.sent(); | ||
return [4 /*yield*/, (0, parse_template_1.parseTemplate)(this.args, validTemplates)]; | ||
case 8: | ||
template = _e.sent(); | ||
projectDir = projectName === '.' ? process.cwd() : "./".concat((0, slugify_1.default)(projectName)); | ||
return [4 /*yield*/, getPackageManager(this.args)]; | ||
case 9: | ||
packageManager = _e.sent(); | ||
if (!(template.type !== 'plugin')) return [3 /*break*/, 15]; | ||
return [4 /*yield*/, (0, select_db_1.selectDb)(this.args, projectName)]; | ||
case 10: | ||
dbDetails = _e.sent(); | ||
return [4 /*yield*/, (0, generate_secret_1.generateSecret)()]; | ||
case 11: | ||
payloadSecret = _e.sent(); | ||
if (!!this.args['--dry-run']) return [3 /*break*/, 14]; | ||
return [4 /*yield*/, (0, create_project_1.createProject)({ | ||
cliArgs: this.args, | ||
projectName: projectName, | ||
projectDir: projectDir, | ||
template: template, | ||
packageManager: packageManager, | ||
dbDetails: dbDetails, | ||
})]; | ||
case 12: | ||
_e.sent(); | ||
return [4 /*yield*/, (0, write_env_file_1.writeEnvFile)({ | ||
databaseUri: dbDetails.dbUri, | ||
payloadSecret: payloadSecret, | ||
template: template, | ||
projectDir: projectDir, | ||
})]; | ||
case 13: | ||
_e.sent(); | ||
_e.label = 14; | ||
case 14: return [3 /*break*/, 17]; | ||
case 15: | ||
if (!!this.args['--dry-run']) return [3 /*break*/, 17]; | ||
return [4 /*yield*/, (0, create_project_1.createProject)({ | ||
cliArgs: this.args, | ||
projectName: projectName, | ||
projectDir: projectDir, | ||
template: template, | ||
packageManager: packageManager, | ||
})]; | ||
case 16: | ||
_e.sent(); | ||
_e.label = 17; | ||
case 17: | ||
(0, log_1.success)('Payload project successfully created'); | ||
console.log((0, messages_1.successMessage)(projectDir, packageManager)); | ||
return [3 /*break*/, 19]; | ||
case 18: | ||
error_1 = _e.sent(); | ||
console.log(error_1); | ||
return [3 /*break*/, 19]; | ||
case 19: return [2 /*return*/]; | ||
async init() { | ||
try { | ||
if (this.args['--help']) { | ||
console.log((0, _messages.helpMessage)()); | ||
process.exit(0); | ||
} | ||
const templateArg = this.args['--template']; | ||
if (templateArg) { | ||
const valid = (0, _templates.validateTemplate)(templateArg); | ||
if (!valid) { | ||
console.log((0, _messages.helpMessage)()); | ||
process.exit(1); | ||
} | ||
}); | ||
}); | ||
}; | ||
return Main; | ||
}()); | ||
exports.Main = Main; | ||
function getPackageManager(args) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var packageManager, error_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
packageManager = 'npm'; | ||
if (!args['--use-npm']) return [3 /*break*/, 1]; | ||
packageManager = 'npm'; | ||
return [3 /*break*/, 9]; | ||
case 1: | ||
if (!args['--use-yarn']) return [3 /*break*/, 2]; | ||
packageManager = 'yarn'; | ||
return [3 /*break*/, 9]; | ||
case 2: | ||
if (!args['--use-pnpm']) return [3 /*break*/, 3]; | ||
packageManager = 'pnpm'; | ||
return [3 /*break*/, 9]; | ||
case 3: | ||
_a.trys.push([3, 8, , 9]); | ||
return [4 /*yield*/, (0, command_exists_1.default)('yarn')]; | ||
case 4: | ||
if (!_a.sent()) return [3 /*break*/, 5]; | ||
packageManager = 'yarn'; | ||
return [3 /*break*/, 7]; | ||
case 5: return [4 /*yield*/, (0, command_exists_1.default)('pnpm')]; | ||
case 6: | ||
if (_a.sent()) { | ||
packageManager = 'pnpm'; | ||
} | ||
_a.label = 7; | ||
case 7: return [3 /*break*/, 9]; | ||
case 8: | ||
error_2 = _a.sent(); | ||
packageManager = 'npm'; | ||
return [3 /*break*/, 9]; | ||
case 9: return [2 /*return*/, packageManager]; | ||
} | ||
}); | ||
}); | ||
console.log(_messages.welcomeMessage); | ||
const projectName = await (0, _parseprojectname.parseProjectName)(this.args); | ||
const validTemplates = (0, _templates.getValidTemplates)(); | ||
const template = await (0, _parsetemplate.parseTemplate)(this.args, validTemplates); | ||
const projectDir = projectName === '.' ? process.cwd() : `./${(0, _slugify.default)(projectName)}`; | ||
const packageManager = await getPackageManager(this.args); | ||
if (template.type !== 'plugin') { | ||
const dbDetails = await (0, _selectdb.selectDb)(this.args, projectName); | ||
const payloadSecret = (0, _generatesecret.generateSecret)(); | ||
if (!this.args['--dry-run']) { | ||
await (0, _createproject.createProject)({ | ||
cliArgs: this.args, | ||
dbDetails, | ||
packageManager, | ||
projectDir, | ||
projectName, | ||
template | ||
}); | ||
await (0, _writeenvfile.writeEnvFile)({ | ||
databaseUri: dbDetails.dbUri, | ||
payloadSecret, | ||
projectDir, | ||
template | ||
}); | ||
} | ||
} else { | ||
if (!this.args['--dry-run']) { | ||
await (0, _createproject.createProject)({ | ||
cliArgs: this.args, | ||
packageManager, | ||
projectDir, | ||
projectName, | ||
template | ||
}); | ||
} | ||
} | ||
(0, _log.success)('Payload project successfully created'); | ||
console.log((0, _messages.successMessage)(projectDir, packageManager)); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
} | ||
async function getPackageManager(args) { | ||
let packageManager = 'npm'; | ||
if (args['--use-npm']) { | ||
packageManager = 'npm'; | ||
} else if (args['--use-yarn']) { | ||
packageManager = 'yarn'; | ||
} else if (args['--use-pnpm']) { | ||
packageManager = 'pnpm'; | ||
} else { | ||
try { | ||
if (await (0, _commandexists.default)('yarn')) { | ||
packageManager = 'yarn'; | ||
} else if (await (0, _commandexists.default)('pnpm')) { | ||
packageManager = 'pnpm'; | ||
} | ||
} catch (error) { | ||
packageManager = 'npm'; | ||
} | ||
} | ||
return packageManager; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9tYWluLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBzbHVnaWZ5IGZyb20gJ0BzaW5kcmVzb3JodXMvc2x1Z2lmeSdcbmltcG9ydCBhcmcgZnJvbSAnYXJnJ1xuaW1wb3J0IGNvbW1hbmRFeGlzdHMgZnJvbSAnY29tbWFuZC1leGlzdHMnXG5cbmltcG9ydCB0eXBlIHsgQ2xpQXJncywgUGFja2FnZU1hbmFnZXIgfSBmcm9tICcuL3R5cGVzJ1xuXG5pbXBvcnQgeyBjcmVhdGVQcm9qZWN0IH0gZnJvbSAnLi9saWIvY3JlYXRlLXByb2plY3QnXG5pbXBvcnQgeyBnZW5lcmF0ZVNlY3JldCB9IGZyb20gJy4vbGliL2dlbmVyYXRlLXNlY3JldCdcbmltcG9ydCB7IHBhcnNlUHJvamVjdE5hbWUgfSBmcm9tICcuL2xpYi9wYXJzZS1wcm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FHLENBQUMrQjtRQUNkO0lBQ0Y7QUFDRjtBQUVBLGVBQWViLGtCQUFrQjFCLElBQWE7SUFDNUMsSUFBSXlCLGlCQUFpQztJQUVyQyxJQUFJekIsSUFBSSxDQUFDLFlBQVksRUFBRTtRQUNyQnlCLGlCQUFpQjtJQUNuQixPQUFPLElBQUl6QixJQUFJLENBQUMsYUFBYSxFQUFFO1FBQzdCeUIsaUJBQWlCO0lBQ25CLE9BQU8sSUFBSXpCLElBQUksQ0FBQyxhQUFhLEVBQUU7UUFDN0J5QixpQkFBaUI7SUFDbkIsT0FBTztRQUNMLElBQUk7WUFDRixJQUFJLE1BQU1lLElBQUFBLHNCQUFhLEVBQUMsU0FBUztnQkFDL0JmLGlCQUFpQjtZQUNuQixPQUFPLElBQUksTUFBTWUsSUFBQUEsc0JBQWEsRUFBQyxTQUFTO2dCQUN0Q2YsaUJBQWlCO1lBQ25CO1FBQ0YsRUFBRSxPQUFPYyxPQUFnQjtZQUN2QmQsaUJBQWlCO1FBQ25CO0lBQ0Y7SUFDQSxPQUFPQTtBQUNUIn0= |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9 |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
success: function() { | ||
return success; | ||
}, | ||
warning: function() { | ||
return warning; | ||
}, | ||
info: function() { | ||
return info; | ||
}, | ||
error: function() { | ||
return error; | ||
} | ||
}); | ||
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk")); | ||
const _figures = /*#__PURE__*/ _interop_require_default(require("figures")); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
const success = (message)=>{ | ||
console.log(`${_chalk.default.green(_figures.default.tick)} ${_chalk.default.bold(message)}`); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.error = exports.info = exports.warning = exports.success = void 0; | ||
var chalk_1 = __importDefault(require("chalk")); | ||
var figures_1 = __importDefault(require("figures")); | ||
var success = function (message) { | ||
console.log("".concat(chalk_1.default.green(figures_1.default.tick), " ").concat(chalk_1.default.bold(message))); | ||
const warning = (message)=>{ | ||
console.log(_chalk.default.yellow('? ') + _chalk.default.bold(message)); | ||
}; | ||
exports.success = success; | ||
var warning = function (message) { | ||
console.log(chalk_1.default.yellow('? ') + chalk_1.default.bold(message)); | ||
const info = (message)=>{ | ||
console.log(`${_chalk.default.yellow(_figures.default.info)} ${_chalk.default.bold(message)}`); | ||
}; | ||
exports.warning = warning; | ||
var info = function (message) { | ||
console.log("".concat(chalk_1.default.yellow(figures_1.default.info), " ").concat(chalk_1.default.bold(message))); | ||
const error = (message)=>{ | ||
console.log(`${_chalk.default.red(_figures.default.cross)} ${_chalk.default.bold(message)}`); | ||
}; | ||
exports.info = info; | ||
var error = function (message) { | ||
console.log("".concat(chalk_1.default.red(figures_1.default.cross), " ").concat(chalk_1.default.bold(message))); | ||
}; | ||
exports.error = error; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9sb2cudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IGNoYWxrIGZyb20gJ2NoYWxrJ1xuaW1wb3J0IGZpZ3VyZXMgZnJvbSAnZmlndXJlcydcblxuZXhwb3J0IGNvbnN0IHN1Y2Nlc3MgPSAobWVzc2FnZTogc3RyaW5nKTogdm9pZCA9PiB7XG4gIGN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0ksSUFBSSxDQUFDUCxTQUFTLENBQUM7QUFDbkU7QUFFTyxNQUFNSCxVQUFVLENBQUNHO0lBQ3RCQyxRQUFRQyxHQUFHLENBQUNDLGNBQUssQ0FBQ0ssTUFBTSxDQUFDLFFBQVFMLGNBQUssQ0FBQ0ksSUFBSSxDQUFDUDtBQUM5QztBQUVPLE1BQU1GLE9BQU8sQ0FBQ0U7SUFDbkJDLFFBQVFDLEdBQUcsQ0FBQyxDQUFDLEVBQUVDLGNBQUssQ0FBQ0ssTUFBTSxDQUFDSCxnQkFBTyxDQUFDUCxJQUFJLEVBQUUsQ0FBQyxFQUFFSyxjQUFLLENBQUNJLElBQUksQ0FBQ1AsU0FBUyxDQUFDO0FBQ3BFO0FBRU8sTUFBTUQsUUFBUSxDQUFDQztJQUNwQkMsUUFBUUMsR0FBRyxDQUFDLENBQUMsRUFBRUMsY0FBSyxDQUFDTSxHQUFHLENBQUNKLGdCQUFPLENBQUNLLEtBQUssRUFBRSxDQUFDLEVBQUVQLGNBQUssQ0FBQ0ksSUFBSSxDQUFDUCxTQUFTLENBQUM7QUFDbEUifQ== |
"use strict"; | ||
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { | ||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } | ||
return cooked; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
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) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
}; | ||
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 (g && (g = 0, op[0] && (_ = 0)), _) 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 }; | ||
} | ||
_export(exports, { | ||
welcomeMessage: function() { | ||
return welcomeMessage; | ||
}, | ||
helpMessage: function() { | ||
return helpMessage; | ||
}, | ||
successMessage: function() { | ||
return successMessage; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.successMessage = exports.helpMessage = exports.welcomeMessage = void 0; | ||
var chalk_1 = __importDefault(require("chalk")); | ||
var figures_1 = __importDefault(require("figures")); | ||
var terminal_link_1 = __importDefault(require("terminal-link")); | ||
var templates_1 = require("../lib/templates"); | ||
var path_1 = __importDefault(require("path")); | ||
var header = function (message) { | ||
return "".concat(chalk_1.default.yellow(figures_1.default.star), " ").concat(chalk_1.default.bold(message)); | ||
}; | ||
exports.welcomeMessage = (0, chalk_1.default)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n {green Welcome to Payload. Let's create a project! }\n"], ["\n {green Welcome to Payload. Let's create a project! }\n"]))); | ||
var spacer = ' '.repeat(8); | ||
}); | ||
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk")); | ||
const _figures = /*#__PURE__*/ _interop_require_default(require("figures")); | ||
const _path = /*#__PURE__*/ _interop_require_default(require("path")); | ||
const _terminallink = /*#__PURE__*/ _interop_require_default(require("terminal-link")); | ||
const _templates = require("../lib/templates"); | ||
function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} | ||
const header = (message)=>`${_chalk.default.yellow(_figures.default.star)} ${_chalk.default.bold(message)}`; | ||
const welcomeMessage = (0, _chalk.default)` | ||
{green Welcome to Payload. Let's create a project! } | ||
`; | ||
const spacer = ' '.repeat(8); | ||
function helpMessage() { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var validTemplates; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, (0, templates_1.getValidTemplates)()]; | ||
case 1: | ||
validTemplates = _a.sent(); | ||
return [2 /*return*/, (0, chalk_1.default)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n {bold USAGE}\n\n {dim $} {bold npx create-payload-app}\n {dim $} {bold npx create-payload-app} my-project\n {dim $} {bold npx create-payload-app} -n my-project -t blog\n\n {bold OPTIONS}\n\n -n {underline my-payload-app} Set project name\n -t {underline template_name} Choose specific template\n\n {dim Available templates: ", "}\n\n --use-npm Use npm to install dependencies\n --use-yarn Use yarn to install dependencies\n --use-pnpm Use pnpm to install dependencies\n --no-deps Do not install any dependencies\n -h Show help\n"], ["\n {bold USAGE}\n\n {dim $} {bold npx create-payload-app}\n {dim $} {bold npx create-payload-app} my-project\n {dim $} {bold npx create-payload-app} -n my-project -t blog\n\n {bold OPTIONS}\n\n -n {underline my-payload-app} Set project name\n -t {underline template_name} Choose specific template\n\n {dim Available templates: ", "}\n\n --use-npm Use npm to install dependencies\n --use-yarn Use yarn to install dependencies\n --use-pnpm Use pnpm to install dependencies\n --no-deps Do not install any dependencies\n -h Show help\n"])), formatTemplates(validTemplates))]; | ||
} | ||
}); | ||
}); | ||
const validTemplates = (0, _templates.getValidTemplates)(); | ||
return (0, _chalk.default)` | ||
{bold USAGE} | ||
{dim $} {bold npx create-payload-app} | ||
{dim $} {bold npx create-payload-app} my-project | ||
{dim $} {bold npx create-payload-app} -n my-project -t blog | ||
{bold OPTIONS} | ||
-n {underline my-payload-app} Set project name | ||
-t {underline template_name} Choose specific template | ||
{dim Available templates: ${formatTemplates(validTemplates)}} | ||
--use-npm Use npm to install dependencies | ||
--use-yarn Use yarn to install dependencies | ||
--use-pnpm Use pnpm to install dependencies | ||
--no-deps Do not install any dependencies | ||
-h Show help | ||
`; | ||
} | ||
exports.helpMessage = helpMessage; | ||
function formatTemplates(templates) { | ||
return "\n\n".concat(spacer).concat(templates | ||
.map(function (t) { return "".concat(t.name).concat(' '.repeat(28 - t.name.length)).concat(t.description); }) | ||
.join("\n".concat(spacer))); | ||
return `\n\n${spacer}${templates.map((t)=>`${t.name}${' '.repeat(28 - t.name.length)}${t.description}`).join(`\n${spacer}`)}`; | ||
} | ||
function successMessage(projectDir, packageManager) { | ||
return "\n ".concat(header('Launch Application:'), "\n\n - cd ").concat(projectDir, "\n - ").concat(packageManager === 'yarn' ? 'yarn' : 'npm run', " dev or follow directions in ").concat(createTerminalLink('README.md', "file://".concat(path_1.default.resolve(projectDir, 'README.md'))), "\n\n ").concat(header('Documentation:'), "\n\n - ").concat(createTerminalLink('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload'), "\n - ").concat(createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview'), "\n\n"); | ||
return ` | ||
${header('Launch Application:')} | ||
- cd ${projectDir} | ||
- ${packageManager === 'yarn' ? 'yarn' : 'npm run'} dev or follow directions in ${createTerminalLink('README.md', `file://${_path.default.resolve(projectDir, 'README.md')}`)} | ||
${header('Documentation:')} | ||
- ${createTerminalLink('Getting Started', 'https://payloadcms.com/docs/getting-started/what-is-payload')} | ||
- ${createTerminalLink('Configuration', 'https://payloadcms.com/docs/configuration/overview')} | ||
`; | ||
} | ||
exports.successMessage = successMessage; | ||
// Create terminalLink with fallback for unsupported terminals | ||
function createTerminalLink(text, url) { | ||
return (0, terminal_link_1.default)(text, url, { | ||
fallback: function (text, url) { return "".concat(text, ": ").concat(url); }, | ||
return (0, _terminallink.default)(text, url, { | ||
fallback: (text, url)=>`${text}: ${url}` | ||
}); | ||
} | ||
var templateObject_1, templateObject_2; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9tZXNzYWdlcy50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgY2hhbGsgZnJvbSAnY2hhbGsnXG5pbXBvcnQgZmlndXJlcyBmcm9tICdmaWd1cmVzJ1xuaW1wb3J0IHBhdGggZnJvbSAncGF0aCdcbmltcG9ydCB0ZXJtaW5hbExpbmsgZnJvbSAndGVybWluYWwtbGluaydcblxuaW1wb3J0IHR5cGUgeyBQcm9qZWN0VGVtcGxhdGUgfSBmcm9tICcuLi90eXBlcydcblxuaW1wb3J0IHsgZ2V0VmFsaWRUZW1wbGF0ZXMgfSBmcm9tICc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BRVgsT0FBTyxDQUFDLEVBQUUsQ0FBQztBQUMxQjtBQUVPLFNBQVNSLGVBQWVvQixVQUFrQixFQUFFQyxjQUFzQjtJQUN2RSxPQUFPLENBQUM7RUFDUixFQUFFcEIsT0FBTyx1QkFBdUI7O1NBRXpCLEVBQUVtQixXQUFXO01BQ2hCLEVBQ0FDLG1CQUFtQixTQUFTLFNBQVMsVUFDdEMsNkJBQTZCLEVBQUVDLG1CQUM5QixhQUNBLENBQUMsT0FBTyxFQUFFQyxhQUFJLENBQUNDLE9BQU8sQ0FBQ0osWUFBWSxhQUFhLENBQUMsRUFDakQ7O0VBRUosRUFBRW5CLE9BQU8sa0JBQWtCOztNQUV2QixFQUFFcUIsbUJBQ0YsbUJBQ0EsK0RBQ0E7TUFDQSxFQUFFQSxtQkFBbUIsaUJBQWlCLHNEQUFzRDs7QUFFbEcsQ0FBQztBQUNEO0FBRUEsOERBQThEO0FBQzlELFNBQVNBLG1CQUFtQkcsSUFBWSxFQUFFQyxHQUFXO0lBQ25ELE9BQU9DLElBQUFBLHFCQUFZLEVBQUNGLE1BQU1DLEtBQUs7UUFDN0JFLFVBQVUsQ0FBQ0gsTUFBTUMsTUFBUSxDQUFDLEVBQUVELEtBQUssRUFBRSxFQUFFQyxJQUFJLENBQUM7SUFDNUM7QUFDRiJ9 |
{ | ||
"name": "create-payload-app", | ||
"version": "1.0.0-beta.0", | ||
"license": "MIT", | ||
@@ -7,16 +8,2 @@ "bin": { | ||
}, | ||
"scripts": { | ||
"build": "tsc && yarn copyfiles", | ||
"copyfiles": "copyfiles -u 1 \"src/templates/**\" \"src/lib/common-files/**\" dist", | ||
"clean": "rimraf dist", | ||
"typecheck": "tsc --noEmit", | ||
"lint": "eslint \"src/**/*.ts\"", | ||
"lint:fix": "eslint \"src/**/*.ts\" --fix", | ||
"lint-staged": "lint-staged --quiet", | ||
"test": "jest", | ||
"prepublishOnly": "yarn test && yarn clean && yarn build", | ||
"prepare": "husky install", | ||
"release:beta": "yarn publish --tag beta", | ||
"release": "yarn publish" | ||
}, | ||
"files": [ | ||
@@ -41,3 +28,2 @@ "package.json", | ||
}, | ||
"version": "0.5.2", | ||
"devDependencies": { | ||
@@ -50,27 +36,10 @@ "@types/command-exists": "^1.2.0", | ||
"@types/prompts": "^2.4.1", | ||
"@typescript-eslint/eslint-plugin": "^5.41.0", | ||
"@typescript-eslint/parser": "^5.41.0", | ||
"copyfiles": "^2.4.1", | ||
"eslint": "^7.32.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"husky": "^8.0.1", | ||
"jest": "^27.4.5", | ||
"lint-staged": "^13.0.3", | ||
"prettier": "^2.3.2", | ||
"rimraf": "^4.1.2", | ||
"ts-jest": "^27.1.1", | ||
"typescript": "^4.8.4" | ||
"ts-jest": "^29.1.0" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.{ts,tsx}": [ | ||
"eslint \"src/**/*.ts\" --cache --fix" | ||
] | ||
"scripts": { | ||
"build": "pnpm build:swc", | ||
"build:swc": "swc ./src -d ./dist --config-file .swcrc", | ||
"clean": "rimraf dist", | ||
"test": "jest" | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108204
7
18
1004
1