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

create-payload-app

Package Overview
Dependencies
Maintainers
0
Versions
447
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-payload-app - npm Package Compare versions

Comparing version 3.11.1-canary.54f6c59 to 3.11.1-canary.6d7b3c8

dist/lib/configure-plugin-project.d.ts

11

dist/lib/create-project.d.ts

@@ -1,2 +0,7 @@

import type { CliArgs, DbDetails, PackageManager, ProjectTemplate } from '../types.js';
import type { CliArgs, DbDetails, PackageManager, ProjectExample, ProjectTemplate } from '../types.js';
type TemplateOrExample = {
example: ProjectExample;
} | {
template: ProjectTemplate;
};
export declare function createProject(args: {

@@ -8,4 +13,3 @@ cliArgs: CliArgs;

projectName: string;
template: ProjectTemplate;
}): Promise<void>;
} & TemplateOrExample): Promise<void>;
export declare function updatePackageJSON(args: {

@@ -15,2 +19,3 @@ projectDir: string;

}): Promise<void>;
export {};
//# sourceMappingURL=create-project.d.ts.map

@@ -10,2 +10,4 @@ import * as p from '@clack/prompts';

import { configurePayloadConfig } from './configure-payload-config.js';
import { configurePluginProject } from './configure-plugin-project.js';
import { downloadExample } from './download-example.js';
import { downloadTemplate } from './download-template.js';

@@ -44,3 +46,3 @@ const filename = fileURLToPath(import.meta.url);

export async function createProject(args) {
const { cliArgs, dbDetails, packageManager, projectDir, projectName, template } = args;
const { cliArgs, dbDetails, packageManager, projectDir, projectName } = args;
if (cliArgs['--dry-run']) {

@@ -51,2 +53,7 @@ debug(`Dry run: Creating project in ${chalk.green(projectDir)}`);

await createOrFindProjectDir(projectDir);
if (cliArgs['--local-example']) {
// Copy example from local path. For development purposes.
const localExample = path.resolve(dirname, '../../../../examples/', cliArgs['--local-example']);
await fse.copy(localExample, projectDir);
}
if (cliArgs['--local-template']) {

@@ -56,5 +63,6 @@ // Copy template from local path. For development purposes.

await fse.copy(localTemplate, projectDir);
} else if ('url' in template) {
if (cliArgs['--template-branch']) {
template.url = `${template.url.split('#')?.[0]}#${cliArgs['--template-branch']}`;
} else if ('template' in args && 'url' in args.template) {
const { template } = args;
if (cliArgs['--branch']) {
template.url = `${template.url.split('#')?.[0]}#${cliArgs['--branch']}`;
}

@@ -66,2 +74,12 @@ await downloadTemplate({

});
} else if ('example' in args && 'url' in args.example) {
const { example } = args;
if (cliArgs['--branch']) {
example.url = `${example.url.split('#')?.[0]}#${cliArgs['--branch']}`;
}
await downloadExample({
debug: cliArgs['--debug'],
example,
projectDir
});
}

@@ -74,9 +92,19 @@ const spinner = p.spinner();

});
spinner.message('Configuring Payload...');
await configurePayloadConfig({
dbType: dbDetails?.type,
projectDirOrConfigPath: {
projectDir
if ('template' in args) {
if (args.template.type === 'plugin') {
spinner.message('Configuring Plugin...');
configurePluginProject({
projectDirPath: projectDir,
projectName
});
} else {
spinner.message('Configuring Payload...');
await configurePayloadConfig({
dbType: dbDetails?.type,
projectDirOrConfigPath: {
projectDir
}
});
}
});
}
// Remove yarn.lock file. This is only desired in Payload Cloud.

@@ -83,0 +111,0 @@ const lockPath = path.resolve(projectDir, 'pnpm-lock.yaml');

@@ -43,6 +43,9 @@ import { jest } from '@jest/globals';

description: 'Template for creating a Payload plugin',
url: 'https://github.com/payloadcms/payload-plugin-template'
url: 'https://github.com/payloadcms/payload/templates/plugin'
};
await createProject({
cliArgs: args,
cliArgs: {
...args,
'--local-template': 'plugin'
},
packageManager,

@@ -58,2 +61,24 @@ projectDir,

});
it('creates example', async ()=>{
const projectName = 'custom-server-example';
const example = {
name: 'custom-server',
url: 'https://github.com/payloadcms/payload/examples/custom-server#main'
};
await createProject({
cliArgs: {
...args,
'--local-template': undefined,
'--local-example': 'custom-server'
},
packageManager,
projectDir,
projectName,
example
});
const packageJsonPath = path.resolve(projectDir, 'package.json');
const packageJson = fse.readJsonSync(packageJsonPath);
// Check package name and description
expect(packageJson.name).toStrictEqual(projectName);
});
describe('creates project from template', ()=>{

@@ -60,0 +85,0 @@ const templates = getValidTemplates();

@@ -25,2 +25,8 @@ import { error, info } from '../utils/log.js';

url: `https://github.com/payloadcms/payload/templates/website#main`
},
{
name: 'plugin',
type: 'plugin',
description: 'Template for creating a Payload plugin',
url: 'https://github.com/payloadcms/payload/templates/plugin#main'
}

@@ -27,0 +33,0 @@ ];

@@ -10,2 +10,3 @@ import * as p from '@clack/prompts';

import { createProject } from './lib/create-project.js';
import { parseExample } from './lib/examples.js';
import { generateSecret } from './lib/generate-secret.js';

@@ -27,5 +28,7 @@ import { getPackageManager } from './lib/get-package-manager.js';

this.args = arg({
'--branch': String,
'--db': String,
'--db-accept-recommended': Boolean,
'--db-connection-string': String,
'--example': String,
'--help': Boolean,

@@ -36,3 +39,2 @@ '--local-template': String,

'--template': String,
'--template-branch': String,
// Next.js

@@ -54,2 +56,3 @@ '--init-next': Boolean,

'-d': '--db',
'-e': '--example',
'-h': '--help',

@@ -165,47 +168,67 @@ '-n': '--name',

}
const exampleArg = this.args['--example'];
if (exampleArg) {
const example = await parseExample({
name: exampleArg,
branch: this.args['--branch'] ?? 'main'
});
if (!example) {
helpMessage();
process.exit(1);
}
await createProject({
cliArgs: this.args,
example,
packageManager,
projectDir,
projectName
});
}
if (debugFlag) {
debug(`Using templates from git tag: v${PACKAGE_VERSION}`);
debug(`Using ${exampleArg ? 'examples' : 'templates'} from git tag: v${PACKAGE_VERSION}`);
}
const validTemplates = getValidTemplates();
const template = await parseTemplate(this.args, validTemplates);
if (!template) {
p.log.error('Invalid template given');
p.outro(feedbackOutro());
process.exit(1);
if (!exampleArg) {
const validTemplates = getValidTemplates();
const template = await parseTemplate(this.args, validTemplates);
if (!template) {
p.log.error('Invalid template given');
p.outro(feedbackOutro());
process.exit(1);
}
switch(template.type){
case 'plugin':
{
await createProject({
cliArgs: this.args,
packageManager,
projectDir,
projectName,
template
});
break;
}
case 'starter':
{
const dbDetails = await selectDb(this.args, projectName);
const payloadSecret = generateSecret();
await createProject({
cliArgs: this.args,
dbDetails,
packageManager,
projectDir,
projectName,
template
});
await manageEnvFiles({
cliArgs: this.args,
databaseType: dbDetails.type,
databaseUri: dbDetails.dbUri,
payloadSecret,
projectDir,
template
});
break;
}
}
}
switch(template.type){
case 'plugin':
{
await createProject({
cliArgs: this.args,
packageManager,
projectDir,
projectName,
template
});
break;
}
case 'starter':
{
const dbDetails = await selectDb(this.args, projectName);
const payloadSecret = generateSecret();
await createProject({
cliArgs: this.args,
dbDetails,
packageManager,
projectDir,
projectName,
template
});
await manageEnvFiles({
cliArgs: this.args,
databaseType: dbDetails.type,
databaseUri: dbDetails.dbUri,
payloadSecret,
projectDir,
template
});
break;
}
}
info('Payload project successfully created!');

@@ -212,0 +235,0 @@ p.note(successMessage(projectDir, packageManager), chalk.bgGreen(chalk.black(' Next Steps ')));

import type arg from 'arg';
export interface Args extends arg.Spec {
'--beta': BooleanConstructor;
'--branch': StringConstructor;
'--db': StringConstructor;

@@ -9,4 +10,6 @@ '--db-accept-recommended': BooleanConstructor;

'--dry-run': BooleanConstructor;
'--example': StringConstructor;
'--help': BooleanConstructor;
'--init-next': BooleanConstructor;
'--local-example': StringConstructor;
'--local-template': StringConstructor;

@@ -18,3 +21,2 @@ '--name': StringConstructor;

'--template': StringConstructor;
'--template-branch': StringConstructor;
'--use-bun': BooleanConstructor;

@@ -24,2 +26,3 @@ '--use-npm': BooleanConstructor;

'--use-yarn': BooleanConstructor;
'-e': string;
'-h': string;

@@ -31,2 +34,6 @@ '-n': string;

export type ProjectTemplate = GitTemplate | PluginTemplate;
export type ProjectExample = {
name: string;
url: string;
};
/**

@@ -33,0 +40,0 @@ * Template that is cloned verbatim from a git repo

@@ -29,2 +29,3 @@ /* eslint-disable no-console */ import chalk from 'chalk';

-t {underline template_name} Choose specific template
-e {underline example_name} Choose specific exmaple

@@ -31,0 +32,0 @@ {dim Available templates: ${formatTemplates(validTemplates)}}

{
"name": "create-payload-app",
"version": "3.11.1-canary.54f6c59",
"version": "3.11.1-canary.6d7b3c8",
"homepage": "https://payloadcms.com",

@@ -76,3 +76,3 @@ "repository": {

"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
"clean": "rimraf {dist,*.tsbuildinfo}",
"clean": "rimraf -g {dist,*.tsbuildinfo}",
"lint": "eslint .",

@@ -79,0 +79,0 @@ "lint:fix": "eslint . --fix",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc