create-payload-app 3.0.0-alpha.55 → 3.0.0-alpha.60
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/cli.js +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/lib/configure-payload-config.js +12 -27
- package/dist/lib/configure-payload-config.js.map +1 -1
- package/dist/lib/create-project.js +32 -96
- package/dist/lib/create-project.js.map +1 -1
- package/dist/lib/create-project.spec.js +24 -33
- package/dist/lib/create-project.spec.js.map +1 -1
- package/dist/lib/generate-secret.js +3 -13
- package/dist/lib/generate-secret.js.map +1 -1
- package/dist/lib/init-next.js +40 -104
- package/dist/lib/init-next.js.map +1 -1
- package/dist/lib/packages.js +1 -11
- package/dist/lib/packages.js.map +1 -1
- package/dist/lib/parse-project-name.js +8 -64
- package/dist/lib/parse-project-name.js.map +1 -1
- package/dist/lib/parse-template.js +4 -55
- package/dist/lib/parse-template.js.map +1 -1
- package/dist/lib/select-db.js +8 -64
- package/dist/lib/select-db.js.map +1 -1
- package/dist/lib/templates.js +5 -23
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/wrap-next-config.js +18 -41
- package/dist/lib/wrap-next-config.js.map +1 -1
- package/dist/lib/wrap-next-config.spec.js +10 -55
- package/dist/lib/wrap-next-config.spec.js.map +1 -1
- package/dist/lib/write-env-file.js +11 -26
- package/dist/lib/write-env-file.js.map +1 -1
- package/dist/main.js +60 -115
- package/dist/main.js.map +1 -1
- package/dist/scripts/pack-template-files.js +15 -24
- package/dist/scripts/pack-template-files.js.map +1 -1
- package/dist/types.js +1 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/copy-recursive-sync.js +11 -24
- package/dist/utils/copy-recursive-sync.js.map +1 -1
- package/dist/utils/log.js +12 -85
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/messages.js +20 -55
- package/dist/utils/messages.js.map +1 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
@@ -1,82 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
}
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
const _initnext = require("./lib/init-next.js");
|
22
|
-
const _parseprojectname = require("./lib/parse-project-name.js");
|
23
|
-
const _parsetemplate = require("./lib/parse-template.js");
|
24
|
-
const _selectdb = require("./lib/select-db.js");
|
25
|
-
const _templates = require("./lib/templates.js");
|
26
|
-
const _writeenvfile = require("./lib/write-env-file.js");
|
27
|
-
const _log = require("./utils/log.js");
|
28
|
-
const _messages = require("./utils/messages.js");
|
29
|
-
function _interop_require_default(obj) {
|
30
|
-
return obj && obj.__esModule ? obj : {
|
31
|
-
default: obj
|
32
|
-
};
|
33
|
-
}
|
34
|
-
function _getRequireWildcardCache(nodeInterop) {
|
35
|
-
if (typeof WeakMap !== "function") return null;
|
36
|
-
var cacheBabelInterop = new WeakMap();
|
37
|
-
var cacheNodeInterop = new WeakMap();
|
38
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
39
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
40
|
-
})(nodeInterop);
|
41
|
-
}
|
42
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
43
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
44
|
-
return obj;
|
45
|
-
}
|
46
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
47
|
-
return {
|
48
|
-
default: obj
|
49
|
-
};
|
50
|
-
}
|
51
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
52
|
-
if (cache && cache.has(obj)) {
|
53
|
-
return cache.get(obj);
|
54
|
-
}
|
55
|
-
var newObj = {
|
56
|
-
__proto__: null
|
57
|
-
};
|
58
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
59
|
-
for(var key in obj){
|
60
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
61
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
62
|
-
if (desc && (desc.get || desc.set)) {
|
63
|
-
Object.defineProperty(newObj, key, desc);
|
64
|
-
} else {
|
65
|
-
newObj[key] = obj[key];
|
66
|
-
}
|
67
|
-
}
|
68
|
-
}
|
69
|
-
newObj.default = obj;
|
70
|
-
if (cache) {
|
71
|
-
cache.set(obj, newObj);
|
72
|
-
}
|
73
|
-
return newObj;
|
74
|
-
}
|
75
|
-
class Main {
|
1
|
+
import * as p from '@clack/prompts';
|
2
|
+
import slugify from '@sindresorhus/slugify';
|
3
|
+
import arg from 'arg';
|
4
|
+
import chalk from 'chalk';
|
5
|
+
// @ts-expect-error no types
|
6
|
+
import { detect } from 'detect-package-manager';
|
7
|
+
import figures from 'figures';
|
8
|
+
import path from 'path';
|
9
|
+
import { configurePayloadConfig } from './lib/configure-payload-config.js';
|
10
|
+
import { createProject } from './lib/create-project.js';
|
11
|
+
import { generateSecret } from './lib/generate-secret.js';
|
12
|
+
import { getNextAppDetails, initNext } from './lib/init-next.js';
|
13
|
+
import { parseProjectName } from './lib/parse-project-name.js';
|
14
|
+
import { parseTemplate } from './lib/parse-template.js';
|
15
|
+
import { selectDb } from './lib/select-db.js';
|
16
|
+
import { getValidTemplates, validateTemplate } from './lib/templates.js';
|
17
|
+
import { writeEnvFile } from './lib/write-env-file.js';
|
18
|
+
import { error, info } from './utils/log.js';
|
19
|
+
import { feedbackOutro, helpMessage, moveMessage, successMessage, successfulNextInit } from './utils/messages.js';
|
20
|
+
export class Main {
|
76
21
|
args;
|
77
22
|
constructor(){
|
78
23
|
// @ts-expect-error bad typings
|
79
|
-
this.args = (
|
24
|
+
this.args = arg({
|
80
25
|
'--db': String,
|
81
26
|
'--db-accept-recommended': Boolean,
|
82
27
|
'--db-connection-string': String,
|
@@ -109,43 +54,43 @@ class Main {
|
|
109
54
|
async init() {
|
110
55
|
try {
|
111
56
|
if (this.args['--help']) {
|
112
|
-
|
57
|
+
helpMessage();
|
113
58
|
process.exit(0);
|
114
59
|
}
|
115
60
|
// eslint-disable-next-line no-console
|
116
61
|
console.log('\n');
|
117
|
-
|
118
|
-
|
62
|
+
p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')));
|
63
|
+
p.note("Welcome to Payload. Let's create a project!");
|
119
64
|
// Detect if inside Next.js project
|
120
|
-
const nextAppDetails = await
|
65
|
+
const nextAppDetails = await getNextAppDetails(process.cwd());
|
121
66
|
const { hasTopLevelLayout, nextAppDir, nextConfigPath } = nextAppDetails;
|
122
67
|
if (nextConfigPath) {
|
123
|
-
this.args['--name'] = (
|
68
|
+
this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath)));
|
124
69
|
}
|
125
|
-
const projectName = await
|
126
|
-
const projectDir = nextConfigPath ?
|
70
|
+
const projectName = await parseProjectName(this.args);
|
71
|
+
const projectDir = nextConfigPath ? path.dirname(nextConfigPath) : path.resolve(process.cwd(), slugify(projectName));
|
127
72
|
const packageManager = await getPackageManager(this.args, projectDir);
|
128
73
|
if (nextConfigPath) {
|
129
|
-
|
130
|
-
const proceed = await
|
74
|
+
p.log.step(chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`));
|
75
|
+
const proceed = await p.confirm({
|
131
76
|
initialValue: true,
|
132
|
-
message:
|
77
|
+
message: chalk.bold(`Install ${chalk.green('Payload')} in this project?`)
|
133
78
|
});
|
134
|
-
if (
|
135
|
-
|
79
|
+
if (p.isCancel(proceed) || !proceed) {
|
80
|
+
p.outro(feedbackOutro());
|
136
81
|
process.exit(0);
|
137
82
|
}
|
138
83
|
// Check for top-level layout.tsx
|
139
84
|
if (nextAppDir && hasTopLevelLayout) {
|
140
|
-
|
85
|
+
p.log.warn(moveMessage({
|
141
86
|
nextAppDir,
|
142
87
|
projectDir
|
143
88
|
}));
|
144
|
-
|
89
|
+
p.outro(feedbackOutro());
|
145
90
|
process.exit(0);
|
146
91
|
}
|
147
|
-
const dbDetails = await
|
148
|
-
const result = await
|
92
|
+
const dbDetails = await selectDb(this.args, projectName);
|
93
|
+
const result = await initNext({
|
149
94
|
...this.args,
|
150
95
|
dbType: dbDetails.type,
|
151
96
|
nextAppDetails,
|
@@ -153,47 +98,47 @@ class Main {
|
|
153
98
|
projectDir
|
154
99
|
});
|
155
100
|
if (result.success === false) {
|
156
|
-
|
101
|
+
p.outro(feedbackOutro());
|
157
102
|
process.exit(1);
|
158
103
|
}
|
159
|
-
await
|
104
|
+
await configurePayloadConfig({
|
160
105
|
dbDetails,
|
161
106
|
projectDirOrConfigPath: {
|
162
107
|
payloadConfigPath: result.payloadConfigPath
|
163
108
|
}
|
164
109
|
});
|
165
|
-
await
|
110
|
+
await writeEnvFile({
|
166
111
|
cliArgs: this.args,
|
167
112
|
databaseUri: dbDetails.dbUri,
|
168
|
-
payloadSecret:
|
113
|
+
payloadSecret: generateSecret(),
|
169
114
|
projectDir
|
170
115
|
});
|
171
|
-
|
172
|
-
|
173
|
-
|
116
|
+
info('Payload project successfully initialized!');
|
117
|
+
p.note(successfulNextInit(), chalk.bgGreen(chalk.black(' Documentation ')));
|
118
|
+
p.outro(feedbackOutro());
|
174
119
|
return;
|
175
120
|
}
|
176
121
|
const templateArg = this.args['--template'];
|
177
122
|
if (templateArg) {
|
178
|
-
const valid =
|
123
|
+
const valid = validateTemplate(templateArg);
|
179
124
|
if (!valid) {
|
180
|
-
|
125
|
+
helpMessage();
|
181
126
|
process.exit(1);
|
182
127
|
}
|
183
128
|
}
|
184
|
-
const validTemplates =
|
185
|
-
const template = await
|
129
|
+
const validTemplates = getValidTemplates();
|
130
|
+
const template = await parseTemplate(this.args, validTemplates);
|
186
131
|
if (!template) {
|
187
|
-
|
188
|
-
|
132
|
+
p.log.error('Invalid template given');
|
133
|
+
p.outro(feedbackOutro());
|
189
134
|
process.exit(1);
|
190
135
|
}
|
191
136
|
switch(template.type){
|
192
137
|
case 'starter':
|
193
138
|
{
|
194
|
-
const dbDetails = await
|
195
|
-
const payloadSecret =
|
196
|
-
await
|
139
|
+
const dbDetails = await selectDb(this.args, projectName);
|
140
|
+
const payloadSecret = generateSecret();
|
141
|
+
await createProject({
|
197
142
|
cliArgs: this.args,
|
198
143
|
dbDetails,
|
199
144
|
packageManager,
|
@@ -201,7 +146,7 @@ class Main {
|
|
201
146
|
projectName,
|
202
147
|
template
|
203
148
|
});
|
204
|
-
await
|
149
|
+
await writeEnvFile({
|
205
150
|
cliArgs: this.args,
|
206
151
|
databaseUri: dbDetails.dbUri,
|
207
152
|
payloadSecret,
|
@@ -212,7 +157,7 @@ class Main {
|
|
212
157
|
}
|
213
158
|
case 'plugin':
|
214
159
|
{
|
215
|
-
await
|
160
|
+
await createProject({
|
216
161
|
cliArgs: this.args,
|
217
162
|
packageManager,
|
218
163
|
projectDir,
|
@@ -222,11 +167,11 @@ class Main {
|
|
222
167
|
break;
|
223
168
|
}
|
224
169
|
}
|
225
|
-
|
226
|
-
|
227
|
-
|
170
|
+
info('Payload project successfully created!');
|
171
|
+
p.note(successMessage(projectDir, packageManager), chalk.bgGreen(chalk.black(' Next Steps ')));
|
172
|
+
p.outro(feedbackOutro());
|
228
173
|
} catch (err) {
|
229
|
-
|
174
|
+
error(err instanceof Error ? err.message : 'An error occurred');
|
230
175
|
}
|
231
176
|
}
|
232
177
|
}
|
@@ -239,7 +184,7 @@ async function getPackageManager(args, projectDir) {
|
|
239
184
|
} else if (args['--use-pnpm']) {
|
240
185
|
packageManager = 'pnpm';
|
241
186
|
} else {
|
242
|
-
const detected = await
|
187
|
+
const detected = await detect({
|
243
188
|
cwd: projectDir
|
244
189
|
});
|
245
190
|
packageManager = detected || 'npm';
|
package/dist/main.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/main.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\nimport arg from 'arg'\nimport chalk from 'chalk'\n// @ts-expect-error no types\nimport { detect } from 'detect-package-manager'\nimport figures from 'figures'\nimport path from 'path'\n\nimport type { CliArgs, PackageManager } from './types.js'\n\nimport { configurePayloadConfig } from './lib/configure-payload-config.js'\nimport { createProject } from './lib/create-project.js'\nimport { generateSecret } from './lib/generate-secret.js'\nimport { getNextAppDetails, initNext } from './lib/init-next.js'\nimport { parseProjectName } from './lib/parse-project-name.js'\nimport { parseTemplate } from './lib/parse-template.js'\nimport { selectDb } from './lib/select-db.js'\nimport { getValidTemplates, validateTemplate } from './lib/templates.js'\nimport { writeEnvFile } from './lib/write-env-file.js'\nimport { error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successMessage,\n successfulNextInit,\n} from './utils/messages.js'\n\nexport class Main {\n args: CliArgs\n\n constructor() {\n // @ts-expect-error bad typings\n this.args = arg(\n {\n '--db': String,\n '--db-accept-recommended': Boolean,\n '--db-connection-string': String,\n '--help': Boolean,\n '--local-template': String,\n '--name': String,\n '--secret': String,\n '--template': String,\n '--template-branch': String,\n\n // Next.js\n '--init-next': Boolean, // TODO: Is this needed if we detect if inside Next.js project?\n\n // Package manager\n '--no-deps': Boolean,\n '--use-npm': Boolean,\n '--use-pnpm': Boolean,\n '--use-yarn': Boolean,\n\n // Flags\n '--beta': Boolean,\n '--debug': Boolean,\n '--dry-run': Boolean,\n\n // Aliases\n '-d': '--db',\n '-h': '--help',\n '-n': '--name',\n '-t': '--template',\n },\n { permissive: true },\n )\n }\n\n async init(): Promise<void> {\n try {\n if (this.args['--help']) {\n helpMessage()\n process.exit(0)\n }\n\n // eslint-disable-next-line no-console\n console.log('\\n')\n p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')))\n p.note(\"Welcome to Payload. Let's create a project!\")\n\n // Detect if inside Next.js project\n const nextAppDetails = await getNextAppDetails(process.cwd())\n const { hasTopLevelLayout, nextAppDir, nextConfigPath } = nextAppDetails\n\n if (nextConfigPath) {\n this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath)))\n }\n\n const projectName = await parseProjectName(this.args)\n const projectDir = nextConfigPath\n ? path.dirname(nextConfigPath)\n : path.resolve(process.cwd(), slugify(projectName))\n\n const packageManager = await getPackageManager(this.args, projectDir)\n\n if (nextConfigPath) {\n p.log.step(\n chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`),\n )\n\n const proceed = await p.confirm({\n initialValue: true,\n message: chalk.bold(`Install ${chalk.green('Payload')} in this project?`),\n })\n if (p.isCancel(proceed) || !proceed) {\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Check for top-level layout.tsx\n if (nextAppDir && hasTopLevelLayout) {\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const dbDetails = await selectDb(this.args, projectName)\n\n const result = await initNext({\n ...this.args,\n dbType: dbDetails.type,\n nextAppDetails,\n packageManager,\n projectDir,\n })\n\n if (result.success === false) {\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n await configurePayloadConfig({\n dbDetails,\n projectDirOrConfigPath: {\n payloadConfigPath: result.payloadConfigPath,\n },\n })\n\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret: generateSecret(),\n projectDir,\n })\n\n info('Payload project successfully initialized!')\n p.note(successfulNextInit(), chalk.bgGreen(chalk.black(' Documentation ')))\n p.outro(feedbackOutro())\n return\n }\n\n const templateArg = this.args['--template']\n if (templateArg) {\n const valid = validateTemplate(templateArg)\n if (!valid) {\n helpMessage()\n process.exit(1)\n }\n }\n\n const validTemplates = getValidTemplates()\n const template = await parseTemplate(this.args, validTemplates)\n if (!template) {\n p.log.error('Invalid template given')\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n switch (template.type) {\n case 'starter': {\n const dbDetails = await selectDb(this.args, projectName)\n const payloadSecret = generateSecret()\n await createProject({\n cliArgs: this.args,\n dbDetails,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret,\n projectDir,\n template,\n })\n break\n }\n case 'plugin': {\n await createProject({\n cliArgs: this.args,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n break\n }\n }\n\n info('Payload project successfully created!')\n p.note(successMessage(projectDir, packageManager), chalk.bgGreen(chalk.black(' Next Steps ')))\n p.outro(feedbackOutro())\n } catch (err: unknown) {\n error(err instanceof Error ? err.message : 'An error occurred')\n }\n }\n}\n\nasync function getPackageManager(args: CliArgs, projectDir: string): Promise<PackageManager> {\n let packageManager: PackageManager = 'npm'\n\n if (args['--use-npm']) {\n packageManager = 'npm'\n } else if (args['--use-yarn']) {\n packageManager = 'yarn'\n } else if (args['--use-pnpm']) {\n packageManager = 'pnpm'\n } else {\n const detected = await detect({ cwd: projectDir })\n packageManager = detected || 'npm'\n }\n return packageManager\n}\n"],"names":["Main","args","constructor","arg","String","Boolean","permissive","init","helpMessage","process","exit","console","log","p","intro","chalk","bgCyan","black","note","nextAppDetails","getNextAppDetails","cwd","hasTopLevelLayout","nextAppDir","nextConfigPath","slugify","path","basename","dirname","projectName","parseProjectName","projectDir","resolve","packageManager","getPackageManager","step","bold","bgBlack","figures","triangleUp","proceed","confirm","initialValue","message","green","isCancel","outro","feedbackOutro","warn","moveMessage","dbDetails","selectDb","result","initNext","dbType","type","success","configurePayloadConfig","projectDirOrConfigPath","payloadConfigPath","writeEnvFile","cliArgs","databaseUri","dbUri","payloadSecret","generateSecret","info","successfulNextInit","bgGreen","templateArg","valid","validateTemplate","validTemplates","getValidTemplates","template","parseTemplate","error","createProject","successMessage","err","Error","detected","detect"],"mappings":";;;;+BA6BaA;;;eAAAA;;;iEA7BM;gEACC;4DACJ;8DACE;sCAEK;gEACH;6DACH;wCAIsB;+BACT;gCACC;0BACa;kCACX;+BACH;0BACL;2BAC2B;8BACvB;qBACD;0BAOrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C;4BACA2C;wBACF;wBACA;oBACF;gBACA,KAAK;oBAAU;wBACb,MAAMG,IAAAA,4BAAa,EAAC;4BAClBhB,SAAS,IAAI,CAAC5D,IAAI;4BAClBgC;4BACAF;4BACAF;4BACA6C;wBACF;wBACA;oBACF;YACF;YAEAR,IAAAA,SAAI,EAAC;YACLrD,SAAEK,IAAI,CAAC4D,IAAAA,wBAAc,EAAC/C,YAAYE,iBAAiBlB,cAAK,CAACqD,OAAO,CAACrD,cAAK,CAACE,KAAK,CAAC;YAC7EJ,SAAEiC,KAAK,CAACC,IAAAA,uBAAa;QACvB,EAAE,OAAOgC,KAAc;YACrBH,IAAAA,UAAK,EAACG,eAAeC,QAAQD,IAAIpC,OAAO,GAAG;QAC7C;IACF;AACF;AAEA,eAAeT,kBAAkBjC,IAAa,EAAE8B,UAAkB;IAChE,IAAIE,iBAAiC;IAErC,IAAIhC,IAAI,CAAC,YAAY,EAAE;QACrBgC,iBAAiB;IACnB,OAAO,IAAIhC,IAAI,CAAC,aAAa,EAAE;QAC7BgC,iBAAiB;IACnB,OAAO,IAAIhC,IAAI,CAAC,aAAa,EAAE;QAC7BgC,iBAAiB;IACnB,OAAO;QACL,MAAMgD,WAAW,MAAMC,IAAAA,4BAAM,EAAC;YAAE7D,KAAKU;QAAW;QAChDE,iBAAiBgD,YAAY;IAC/B;IACA,OAAOhD;AACT"}
|
1
|
+
{"version":3,"sources":["../src/main.ts"],"sourcesContent":["import * as p from '@clack/prompts'\nimport slugify from '@sindresorhus/slugify'\nimport arg from 'arg'\nimport chalk from 'chalk'\n// @ts-expect-error no types\nimport { detect } from 'detect-package-manager'\nimport figures from 'figures'\nimport path from 'path'\n\nimport type { CliArgs, PackageManager } from './types.js'\n\nimport { configurePayloadConfig } from './lib/configure-payload-config.js'\nimport { createProject } from './lib/create-project.js'\nimport { generateSecret } from './lib/generate-secret.js'\nimport { getNextAppDetails, initNext } from './lib/init-next.js'\nimport { parseProjectName } from './lib/parse-project-name.js'\nimport { parseTemplate } from './lib/parse-template.js'\nimport { selectDb } from './lib/select-db.js'\nimport { getValidTemplates, validateTemplate } from './lib/templates.js'\nimport { writeEnvFile } from './lib/write-env-file.js'\nimport { error, info } from './utils/log.js'\nimport {\n feedbackOutro,\n helpMessage,\n moveMessage,\n successMessage,\n successfulNextInit,\n} from './utils/messages.js'\n\nexport class Main {\n args: CliArgs\n\n constructor() {\n // @ts-expect-error bad typings\n this.args = arg(\n {\n '--db': String,\n '--db-accept-recommended': Boolean,\n '--db-connection-string': String,\n '--help': Boolean,\n '--local-template': String,\n '--name': String,\n '--secret': String,\n '--template': String,\n '--template-branch': String,\n\n // Next.js\n '--init-next': Boolean, // TODO: Is this needed if we detect if inside Next.js project?\n\n // Package manager\n '--no-deps': Boolean,\n '--use-npm': Boolean,\n '--use-pnpm': Boolean,\n '--use-yarn': Boolean,\n\n // Flags\n '--beta': Boolean,\n '--debug': Boolean,\n '--dry-run': Boolean,\n\n // Aliases\n '-d': '--db',\n '-h': '--help',\n '-n': '--name',\n '-t': '--template',\n },\n { permissive: true },\n )\n }\n\n async init(): Promise<void> {\n try {\n if (this.args['--help']) {\n helpMessage()\n process.exit(0)\n }\n\n // eslint-disable-next-line no-console\n console.log('\\n')\n p.intro(chalk.bgCyan(chalk.black(' create-payload-app ')))\n p.note(\"Welcome to Payload. Let's create a project!\")\n\n // Detect if inside Next.js project\n const nextAppDetails = await getNextAppDetails(process.cwd())\n const { hasTopLevelLayout, nextAppDir, nextConfigPath } = nextAppDetails\n\n if (nextConfigPath) {\n this.args['--name'] = slugify(path.basename(path.dirname(nextConfigPath)))\n }\n\n const projectName = await parseProjectName(this.args)\n const projectDir = nextConfigPath\n ? path.dirname(nextConfigPath)\n : path.resolve(process.cwd(), slugify(projectName))\n\n const packageManager = await getPackageManager(this.args, projectDir)\n\n if (nextConfigPath) {\n p.log.step(\n chalk.bold(`${chalk.bgBlack(` ${figures.triangleUp} Next.js `)} project detected!`),\n )\n\n const proceed = await p.confirm({\n initialValue: true,\n message: chalk.bold(`Install ${chalk.green('Payload')} in this project?`),\n })\n if (p.isCancel(proceed) || !proceed) {\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n // Check for top-level layout.tsx\n if (nextAppDir && hasTopLevelLayout) {\n p.log.warn(moveMessage({ nextAppDir, projectDir }))\n p.outro(feedbackOutro())\n process.exit(0)\n }\n\n const dbDetails = await selectDb(this.args, projectName)\n\n const result = await initNext({\n ...this.args,\n dbType: dbDetails.type,\n nextAppDetails,\n packageManager,\n projectDir,\n })\n\n if (result.success === false) {\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n await configurePayloadConfig({\n dbDetails,\n projectDirOrConfigPath: {\n payloadConfigPath: result.payloadConfigPath,\n },\n })\n\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret: generateSecret(),\n projectDir,\n })\n\n info('Payload project successfully initialized!')\n p.note(successfulNextInit(), chalk.bgGreen(chalk.black(' Documentation ')))\n p.outro(feedbackOutro())\n return\n }\n\n const templateArg = this.args['--template']\n if (templateArg) {\n const valid = validateTemplate(templateArg)\n if (!valid) {\n helpMessage()\n process.exit(1)\n }\n }\n\n const validTemplates = getValidTemplates()\n const template = await parseTemplate(this.args, validTemplates)\n if (!template) {\n p.log.error('Invalid template given')\n p.outro(feedbackOutro())\n process.exit(1)\n }\n\n switch (template.type) {\n case 'starter': {\n const dbDetails = await selectDb(this.args, projectName)\n const payloadSecret = generateSecret()\n await createProject({\n cliArgs: this.args,\n dbDetails,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n await writeEnvFile({\n cliArgs: this.args,\n databaseUri: dbDetails.dbUri,\n payloadSecret,\n projectDir,\n template,\n })\n break\n }\n case 'plugin': {\n await createProject({\n cliArgs: this.args,\n packageManager,\n projectDir,\n projectName,\n template,\n })\n break\n }\n }\n\n info('Payload project successfully created!')\n p.note(successMessage(projectDir, packageManager), chalk.bgGreen(chalk.black(' Next Steps ')))\n p.outro(feedbackOutro())\n } catch (err: unknown) {\n error(err instanceof Error ? err.message : 'An error occurred')\n }\n }\n}\n\nasync function getPackageManager(args: CliArgs, projectDir: string): Promise<PackageManager> {\n let packageManager: PackageManager = 'npm'\n\n if (args['--use-npm']) {\n packageManager = 'npm'\n } else if (args['--use-yarn']) {\n packageManager = 'yarn'\n } else if (args['--use-pnpm']) {\n packageManager = 'pnpm'\n } else {\n const detected = await detect({ cwd: projectDir })\n packageManager = detected || 'npm'\n }\n return packageManager\n}\n"],"names":["p","slugify","arg","chalk","detect","figures","path","configurePayloadConfig","createProject","generateSecret","getNextAppDetails","initNext","parseProjectName","parseTemplate","selectDb","getValidTemplates","validateTemplate","writeEnvFile","error","info","feedbackOutro","helpMessage","moveMessage","successMessage","successfulNextInit","Main","args","constructor","String","Boolean","permissive","init","process","exit","console","log","intro","bgCyan","black","note","nextAppDetails","cwd","hasTopLevelLayout","nextAppDir","nextConfigPath","basename","dirname","projectName","projectDir","resolve","packageManager","getPackageManager","step","bold","bgBlack","triangleUp","proceed","confirm","initialValue","message","green","isCancel","outro","warn","dbDetails","result","dbType","type","success","projectDirOrConfigPath","payloadConfigPath","cliArgs","databaseUri","dbUri","payloadSecret","bgGreen","templateArg","valid","validTemplates","template","err","Error","detected"],"mappings":"AAAA,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,SAAS,MAAK;AACrB,OAAOC,WAAW,QAAO;AACzB,4BAA4B;AAC5B,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,OAAOC,aAAa,UAAS;AAC7B,OAAOC,UAAU,OAAM;AAIvB,SAASC,sBAAsB,QAAQ,oCAAmC;AAC1E,SAASC,aAAa,QAAQ,0BAAyB;AACvD,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,iBAAiB,EAAEC,QAAQ,QAAQ,qBAAoB;AAChE,SAASC,gBAAgB,QAAQ,8BAA6B;AAC9D,SAASC,aAAa,QAAQ,0BAAyB;AACvD,SAASC,QAAQ,QAAQ,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AI,CAAChB,eAAeyB,YAAYE,iBAAiB/C,MAAMwE,OAAO,CAACxE,MAAMmC,KAAK,CAAC;YAC7EtC,EAAE8D,KAAK,CAAC1C;QACV,EAAE,OAAO4D,KAAc;YACrB9D,MAAM8D,eAAeC,QAAQD,IAAIrB,OAAO,GAAG;QAC7C;IACF;AACF;AAEA,eAAeR,kBAAkBzB,IAAa,EAAEsB,UAAkB;IAChE,IAAIE,iBAAiC;IAErC,IAAIxB,IAAI,CAAC,YAAY,EAAE;QACrBwB,iBAAiB;IACnB,OAAO,IAAIxB,IAAI,CAAC,aAAa,EAAE;QAC7BwB,iBAAiB;IACnB,OAAO,IAAIxB,IAAI,CAAC,aAAa,EAAE;QAC7BwB,iBAAiB;IACnB,OAAO;QACL,MAAMgC,WAAW,MAAM9E,OAAO;YAAEqC,KAAKO;QAAW;QAChDE,iBAAiBgC,YAAY;IAC/B;IACA,OAAOhC;AACT"}
|
@@ -1,18 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
const
|
6
|
-
const
|
7
|
-
const _nodeurl = require("node:url");
|
8
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
9
|
-
function _interop_require_default(obj) {
|
10
|
-
return obj && obj.__esModule ? obj : {
|
11
|
-
default: obj
|
12
|
-
};
|
13
|
-
}
|
14
|
-
const filename = (0, _nodeurl.fileURLToPath)(require("url").pathToFileURL(__filename).toString());
|
15
|
-
const dirname = _path.default.dirname(filename);
|
1
|
+
import fs from 'fs';
|
2
|
+
import fsp from 'fs/promises';
|
3
|
+
import { fileURLToPath } from 'node:url';
|
4
|
+
import path from 'path';
|
5
|
+
const filename = fileURLToPath(import.meta.url);
|
6
|
+
const dirname = path.dirname(filename);
|
16
7
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
17
8
|
main();
|
18
9
|
/**
|
@@ -20,22 +11,22 @@ main();
|
|
20
11
|
*
|
21
12
|
* Eventually, this should be replaced with using tar.x to stream from the git repo
|
22
13
|
*/ async function main() {
|
23
|
-
const root =
|
24
|
-
const outputPath =
|
25
|
-
const sourceTemplatePath =
|
26
|
-
if (!
|
14
|
+
const root = path.resolve(dirname, '../../../../');
|
15
|
+
const outputPath = path.resolve(dirname, '../../dist/template');
|
16
|
+
const sourceTemplatePath = path.resolve(root, 'templates/blank-3.0');
|
17
|
+
if (!fs.existsSync(sourceTemplatePath)) {
|
27
18
|
throw new Error(`Source path does not exist: ${sourceTemplatePath}`);
|
28
19
|
}
|
29
|
-
if (!
|
30
|
-
|
20
|
+
if (!fs.existsSync(outputPath)) {
|
21
|
+
fs.mkdirSync(outputPath, {
|
31
22
|
recursive: true
|
32
23
|
});
|
33
24
|
}
|
34
25
|
// Copy the src directory from `templates/blank-3.0` to `dist`
|
35
|
-
const srcPath =
|
36
|
-
const distSrcPath =
|
26
|
+
const srcPath = path.resolve(sourceTemplatePath, 'src');
|
27
|
+
const distSrcPath = path.resolve(outputPath, 'src');
|
37
28
|
// Copy entire file structure from src to dist
|
38
|
-
await
|
29
|
+
await fsp.cp(srcPath, distSrcPath, {
|
39
30
|
recursive: true
|
40
31
|
});
|
41
32
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/scripts/pack-template-files.ts"],"sourcesContent":["import fs from 'fs'\nimport fsp from 'fs/promises'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\n// eslint-disable-next-line @typescript-eslint/no-floating-promises\nmain()\n\n/**\n * Copy the necessary template files from `templates/blank-3.0` to `dist/template`\n *\n * Eventually, this should be replaced with using tar.x to stream from the git repo\n */\n\nasync function main() {\n const root = path.resolve(dirname, '../../../../')\n const outputPath = path.resolve(dirname, '../../dist/template')\n const sourceTemplatePath = path.resolve(root, 'templates/blank-3.0')\n\n if (!fs.existsSync(sourceTemplatePath)) {\n throw new Error(`Source path does not exist: ${sourceTemplatePath}`)\n }\n\n if (!fs.existsSync(outputPath)) {\n fs.mkdirSync(outputPath, { recursive: true })\n }\n\n // Copy the src directory from `templates/blank-3.0` to `dist`\n const srcPath = path.resolve(sourceTemplatePath, 'src')\n const distSrcPath = path.resolve(outputPath, 'src')\n // Copy entire file structure from src to dist\n await fsp.cp(srcPath, distSrcPath, { recursive: true })\n}\n"],"names":["
|
1
|
+
{"version":3,"sources":["../../src/scripts/pack-template-files.ts"],"sourcesContent":["import fs from 'fs'\nimport fsp from 'fs/promises'\nimport { fileURLToPath } from 'node:url'\nimport path from 'path'\nconst filename = fileURLToPath(import.meta.url)\nconst dirname = path.dirname(filename)\n\n// eslint-disable-next-line @typescript-eslint/no-floating-promises\nmain()\n\n/**\n * Copy the necessary template files from `templates/blank-3.0` to `dist/template`\n *\n * Eventually, this should be replaced with using tar.x to stream from the git repo\n */\n\nasync function main() {\n const root = path.resolve(dirname, '../../../../')\n const outputPath = path.resolve(dirname, '../../dist/template')\n const sourceTemplatePath = path.resolve(root, 'templates/blank-3.0')\n\n if (!fs.existsSync(sourceTemplatePath)) {\n throw new Error(`Source path does not exist: ${sourceTemplatePath}`)\n }\n\n if (!fs.existsSync(outputPath)) {\n fs.mkdirSync(outputPath, { recursive: true })\n }\n\n // Copy the src directory from `templates/blank-3.0` to `dist`\n const srcPath = path.resolve(sourceTemplatePath, 'src')\n const distSrcPath = path.resolve(outputPath, 'src')\n // Copy entire file structure from src to dist\n await fsp.cp(srcPath, distSrcPath, { recursive: true })\n}\n"],"names":["fs","fsp","fileURLToPath","path","filename","url","dirname","main","root","resolve","outputPath","sourceTemplatePath","existsSync","Error","mkdirSync","recursive","srcPath","distSrcPath","cp"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,SAAS,cAAa;AAC7B,SAASC,aAAa,QAAQ,WAAU;AACxC,OAAOC,UAAU,OAAM;AACvB,MAAMC,WAAWF,cAAc,YAAYG,GAAG;AAC9C,MAAMC,UAAUH,KAAKG,OAAO,CAACF;AAE7B,mEAAmE;AACnEG;AAEA;;;;CAIC,GAED,eAAeA;IACb,MAAMC,OAAOL,KAAKM,OAAO,CAACH,SAAS;IACnC,MAAMI,aAAaP,KAAKM,OAAO,CAACH,SAAS;IACzC,MAAMK,qBAAqBR,KAAKM,OAAO,CAACD,MAAM;IAE9C,IAAI,CAACR,GAAGY,UAAU,CAACD,qBAAqB;QACtC,MAAM,IAAIE,MAAM,CAAC,4BAA4B,EAAEF,mBAAmB,CAAC;IACrE;IAEA,IAAI,CAACX,GAAGY,UAAU,CAACF,aAAa;QAC9BV,GAAGc,SAAS,CAACJ,YAAY;YAAEK,WAAW;QAAK;IAC7C;IAEA,8DAA8D;IAC9D,MAAMC,UAAUb,KAAKM,OAAO,CAACE,oBAAoB;IACjD,MAAMM,cAAcd,KAAKM,OAAO,CAACC,YAAY;IAC7C,8CAA8C;IAC9C,MAAMT,IAAIiB,EAAE,CAACF,SAASC,aAAa;QAAEF,WAAW;IAAK;AACvD"}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"names":[],"mappings":""}
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type arg from 'arg'\n\nexport interface Args extends arg.Spec {\n '--beta': BooleanConstructor\n '--db': StringConstructor\n '--db-accept-recommended': BooleanConstructor\n '--db-connection-string': StringConstructor\n '--debug': BooleanConstructor\n '--dry-run': BooleanConstructor\n '--help': BooleanConstructor\n '--init-next': BooleanConstructor\n '--local-template': StringConstructor\n '--name': StringConstructor\n '--no-deps': BooleanConstructor\n '--secret': StringConstructor\n '--template': StringConstructor\n '--template-branch': StringConstructor\n '--use-npm': BooleanConstructor\n '--use-pnpm': BooleanConstructor\n '--use-yarn': BooleanConstructor\n\n // Aliases\n\n '-h': string\n '-n': string\n '-t': string\n}\n\nexport type CliArgs = arg.Result<Args>\n\nexport type ProjectTemplate = GitTemplate | PluginTemplate\n\n/**\n * Template that is cloned verbatim from a git repo\n * Performs .env manipulation based upon input\n */\nexport interface GitTemplate extends Template {\n type: 'starter'\n url: string\n}\n\n/**\n * Type specifically for the plugin template\n * No .env manipulation is done\n */\nexport interface PluginTemplate extends Template {\n type: 'plugin'\n url: string\n}\n\ninterface Template {\n description?: string\n name: string\n type: ProjectTemplate['type']\n}\n\nexport type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn'\n\nexport type DbType = 'mongodb' | 'postgres'\n\nexport type DbDetails = {\n dbUri: string\n type: DbType\n}\n\nexport type EditorType = 'lexical' | 'slate'\n"],"names":[],"mappings":"AAiEA,WAA4C"}
|
@@ -1,33 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
return copyRecursiveSync;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
12
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
13
|
-
function _interop_require_default(obj) {
|
14
|
-
return obj && obj.__esModule ? obj : {
|
15
|
-
default: obj
|
16
|
-
};
|
17
|
-
}
|
18
|
-
function copyRecursiveSync(src, dest, debug) {
|
19
|
-
const exists = _fs.default.existsSync(src);
|
20
|
-
const stats = exists && _fs.default.statSync(src);
|
1
|
+
import fs from 'fs';
|
2
|
+
import path from 'path';
|
3
|
+
/**
|
4
|
+
* Recursively copy files from src to dest
|
5
|
+
*/ export function copyRecursiveSync(src, dest, debug) {
|
6
|
+
const exists = fs.existsSync(src);
|
7
|
+
const stats = exists && fs.statSync(src);
|
21
8
|
const isDirectory = exists && stats !== false && stats.isDirectory();
|
22
9
|
if (isDirectory) {
|
23
|
-
|
10
|
+
fs.mkdirSync(dest, {
|
24
11
|
recursive: true
|
25
12
|
});
|
26
|
-
|
27
|
-
copyRecursiveSync(
|
13
|
+
fs.readdirSync(src).forEach((childItemName)=>{
|
14
|
+
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName));
|
28
15
|
});
|
29
16
|
} else {
|
30
|
-
|
17
|
+
fs.copyFileSync(src, dest);
|
31
18
|
}
|
32
19
|
}
|
33
20
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/copy-recursive-sync.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\n\n/**\n * Recursively copy files from src to dest\n */\nexport function copyRecursiveSync(src: string, dest: string, debug?: boolean) {\n const exists = fs.existsSync(src)\n const stats = exists && fs.statSync(src)\n const isDirectory = exists && stats !== false && stats.isDirectory()\n if (isDirectory) {\n fs.mkdirSync(dest, { recursive: true })\n fs.readdirSync(src).forEach((childItemName) => {\n copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName))\n })\n } else {\n fs.copyFileSync(src, dest)\n }\n}\n"],"names":["copyRecursiveSync","src","dest","debug","exists","
|
1
|
+
{"version":3,"sources":["../../src/utils/copy-recursive-sync.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\n\n/**\n * Recursively copy files from src to dest\n */\nexport function copyRecursiveSync(src: string, dest: string, debug?: boolean) {\n const exists = fs.existsSync(src)\n const stats = exists && fs.statSync(src)\n const isDirectory = exists && stats !== false && stats.isDirectory()\n if (isDirectory) {\n fs.mkdirSync(dest, { recursive: true })\n fs.readdirSync(src).forEach((childItemName) => {\n copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName))\n })\n } else {\n fs.copyFileSync(src, dest)\n }\n}\n"],"names":["fs","path","copyRecursiveSync","src","dest","debug","exists","existsSync","stats","statSync","isDirectory","mkdirSync","recursive","readdirSync","forEach","childItemName","join","copyFileSync"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AAEvB;;CAEC,GACD,OAAO,SAASC,kBAAkBC,GAAW,EAAEC,IAAY,EAAEC,KAAe;IAC1E,MAAMC,SAASN,GAAGO,UAAU,CAACJ;IAC7B,MAAMK,QAAQF,UAAUN,GAAGS,QAAQ,CAACN;IACpC,MAAMO,cAAcJ,UAAUE,UAAU,SAASA,MAAME,WAAW;IAClE,IAAIA,aAAa;QACfV,GAAGW,SAAS,CAACP,MAAM;YAAEQ,WAAW;QAAK;QACrCZ,GAAGa,WAAW,CAACV,KAAKW,OAAO,CAAC,CAACC;YAC3Bb,kBAAkBD,KAAKe,IAAI,CAACb,KAAKY,gBAAgBd,KAAKe,IAAI,CAACZ,MAAMW;QACnE;IACF,OAAO;QACLf,GAAGiB,YAAY,CAACd,KAAKC;IACvB;AACF"}
|
package/dist/utils/log.js
CHANGED
@@ -1,92 +1,19 @@
|
|
1
|
-
/* eslint-disable no-console */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
function _export(target, all) {
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
7
|
-
enumerable: true,
|
8
|
-
get: all[name]
|
9
|
-
});
|
10
|
-
}
|
11
|
-
_export(exports, {
|
12
|
-
debug: function() {
|
13
|
-
return debug;
|
14
|
-
},
|
15
|
-
error: function() {
|
16
|
-
return error;
|
17
|
-
},
|
18
|
-
info: function() {
|
19
|
-
return info;
|
20
|
-
},
|
21
|
-
log: function() {
|
22
|
-
return log;
|
23
|
-
},
|
24
|
-
warning: function() {
|
25
|
-
return warning;
|
26
|
-
}
|
27
|
-
});
|
28
|
-
const _prompts = /*#__PURE__*/ _interop_require_wildcard(require("@clack/prompts"));
|
29
|
-
const _chalk = /*#__PURE__*/ _interop_require_default(require("chalk"));
|
30
|
-
function _interop_require_default(obj) {
|
31
|
-
return obj && obj.__esModule ? obj : {
|
32
|
-
default: obj
|
33
|
-
};
|
34
|
-
}
|
35
|
-
function _getRequireWildcardCache(nodeInterop) {
|
36
|
-
if (typeof WeakMap !== "function") return null;
|
37
|
-
var cacheBabelInterop = new WeakMap();
|
38
|
-
var cacheNodeInterop = new WeakMap();
|
39
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
40
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
41
|
-
})(nodeInterop);
|
42
|
-
}
|
43
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
44
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
45
|
-
return obj;
|
46
|
-
}
|
47
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
48
|
-
return {
|
49
|
-
default: obj
|
50
|
-
};
|
51
|
-
}
|
52
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
53
|
-
if (cache && cache.has(obj)) {
|
54
|
-
return cache.get(obj);
|
55
|
-
}
|
56
|
-
var newObj = {
|
57
|
-
__proto__: null
|
58
|
-
};
|
59
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
60
|
-
for(var key in obj){
|
61
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
62
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
63
|
-
if (desc && (desc.get || desc.set)) {
|
64
|
-
Object.defineProperty(newObj, key, desc);
|
65
|
-
} else {
|
66
|
-
newObj[key] = obj[key];
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
newObj.default = obj;
|
71
|
-
if (cache) {
|
72
|
-
cache.set(obj, newObj);
|
73
|
-
}
|
74
|
-
return newObj;
|
75
|
-
}
|
76
|
-
const warning = (message)=>{
|
77
|
-
_prompts.log.warn(_chalk.default.yellow('? ') + _chalk.default.bold(message));
|
1
|
+
/* eslint-disable no-console */ import * as p from '@clack/prompts';
|
2
|
+
import chalk from 'chalk';
|
3
|
+
export const warning = (message)=>{
|
4
|
+
p.log.warn(chalk.yellow('? ') + chalk.bold(message));
|
78
5
|
};
|
79
|
-
const info = (message)=>{
|
80
|
-
|
6
|
+
export const info = (message)=>{
|
7
|
+
p.log.step(chalk.bold(message));
|
81
8
|
};
|
82
|
-
const error = (message)=>{
|
83
|
-
|
9
|
+
export const error = (message)=>{
|
10
|
+
p.log.error(chalk.bold(message));
|
84
11
|
};
|
85
|
-
const debug = (message)=>{
|
86
|
-
|
12
|
+
export const debug = (message)=>{
|
13
|
+
p.log.step(`${chalk.bgGray('[DEBUG]')} ${chalk.gray(message)}`);
|
87
14
|
};
|
88
|
-
const log = (message)=>{
|
89
|
-
|
15
|
+
export const log = (message)=>{
|
16
|
+
p.log.message(message);
|
90
17
|
};
|
91
18
|
|
92
19
|
//# sourceMappingURL=log.js.map
|
package/dist/utils/log.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/utils/log.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport * as p from '@clack/prompts'\nimport chalk from 'chalk'\n\nexport const warning = (message: string): void => {\n p.log.warn(chalk.yellow('? ') + chalk.bold(message))\n}\n\nexport const info = (message: string): void => {\n p.log.step(chalk.bold(message))\n}\n\nexport const error = (message: string): void => {\n p.log.error(chalk.bold(message))\n}\n\nexport const debug = (message: string): void => {\n p.log.step(`${chalk.bgGray('[DEBUG]')} ${chalk.gray(message)}`)\n}\n\nexport const log = (message: string): void => {\n p.log.message(message)\n}\n"],"names":["
|
1
|
+
{"version":3,"sources":["../../src/utils/log.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport * as p from '@clack/prompts'\nimport chalk from 'chalk'\n\nexport const warning = (message: string): void => {\n p.log.warn(chalk.yellow('? ') + chalk.bold(message))\n}\n\nexport const info = (message: string): void => {\n p.log.step(chalk.bold(message))\n}\n\nexport const error = (message: string): void => {\n p.log.error(chalk.bold(message))\n}\n\nexport const debug = (message: string): void => {\n p.log.step(`${chalk.bgGray('[DEBUG]')} ${chalk.gray(message)}`)\n}\n\nexport const log = (message: string): void => {\n p.log.message(message)\n}\n"],"names":["p","chalk","warning","message","log","warn","yellow","bold","info","step","error","debug","bgGray","gray"],"mappings":"AAAA,6BAA6B,GAC7B,YAAYA,OAAO,iBAAgB;AACnC,OAAOC,WAAW,QAAO;AAEzB,OAAO,MAAMC,UAAU,CAACC;IACtBH,EAAEI,GAAG,CAACC,IAAI,CAACJ,MAAMK,MAAM,CAAC,QAAQL,MAAMM,IAAI,CAACJ;AAC7C,EAAC;AAED,OAAO,MAAMK,OAAO,CAACL;IACnBH,EAAEI,GAAG,CAACK,IAAI,CAACR,MAAMM,IAAI,CAACJ;AACxB,EAAC;AAED,OAAO,MAAMO,QAAQ,CAACP;IACpBH,EAAEI,GAAG,CAACM,KAAK,CAACT,MAAMM,IAAI,CAACJ;AACzB,EAAC;AAED,OAAO,MAAMQ,QAAQ,CAACR;IACpBH,EAAEI,GAAG,CAACK,IAAI,CAAC,CAAC,EAAER,MAAMW,MAAM,CAAC,WAAW,CAAC,EAAEX,MAAMY,IAAI,CAACV,SAAS,CAAC;AAChE,EAAC;AAED,OAAO,MAAMC,MAAM,CAACD;IAClBH,EAAEI,GAAG,CAACD,OAAO,CAACA;AAChB,EAAC"}
|