@stacksjs/actions 0.58.48 → 0.58.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/generate/ide-helpers.js +1 -0
- package/dist/src/generate/lib-entries.js +4 -2
- package/dist/src/generate/vscode-custom-data.js +1 -0
- package/dist/src/helpers/lib-entries.js +1 -0
- package/dist/src/helpers/package-json.js +1 -0
- package/dist/src/helpers/vscode-custom-data.js +1 -0
- package/dist/src/upgrade.js +1 -1
- package/package.json +3 -2
- package/src/action.ts +11 -0
- package/src/actions.ts +2 -0
- package/src/add.ts +27 -0
- package/src/ai/request-model-access.ts +74 -0
- package/src/build/cli.ts +7 -0
- package/src/build/component-libs.ts +5 -0
- package/src/build/core.ts +34 -0
- package/src/build/desktop.ts +7 -0
- package/src/build/docs.ts +7 -0
- package/src/build/stacks.ts +7 -0
- package/src/build.ts +89 -0
- package/src/bump.ts +11 -0
- package/src/cdn/invalidate-cache.ts +27 -0
- package/src/changelog.ts +11 -0
- package/src/clean.ts +6 -0
- package/src/commit.ts +14 -0
- package/src/copy-types.ts +22 -0
- package/src/database/fields.ts +111 -0
- package/src/database/migration-mysql.ts +72 -0
- package/src/database/migration-sqlite.ts +67 -0
- package/src/database/migration.ts +10 -0
- package/src/database/mydb.sqlite +0 -0
- package/src/database/seed.ts +4 -0
- package/src/database/stacks.sqlite +0 -0
- package/src/database/user-migration.ts +20 -0
- package/src/deploy/create-receipt-rule.ts +55 -0
- package/src/deploy/index.ts +46 -0
- package/src/dev/api.ts +19 -0
- package/src/dev/components.ts +14 -0
- package/src/dev/dashboard.ts +7 -0
- package/src/dev/desktop.ts +7 -0
- package/src/dev/docs.ts +7 -0
- package/src/dev/index.ts +48 -0
- package/src/dev/system-tray.ts +6 -0
- package/src/dev/views.ts +7 -0
- package/src/domains/add.ts +82 -0
- package/src/domains/purchase.ts +76 -0
- package/src/domains/remove.ts +38 -0
- package/src/examples.ts +46 -0
- package/src/fresh.ts +20 -0
- package/src/generate/caddyfile.ts +1 -0
- package/src/generate/component-meta.ts +19 -0
- package/src/generate/env-files.ts +89 -0
- package/src/generate/ide-helpers.ts +18 -0
- package/src/generate/index.ts +132 -0
- package/src/generate/lib-entries.ts +18 -0
- package/src/generate/model-classes.ts +299 -0
- package/src/generate/model-generate.ts +12 -0
- package/src/generate/pkgx-file.ts +72 -0
- package/src/generate/types.ts +6 -0
- package/src/generate/vscode-custom-data.ts +19 -0
- package/src/generate/web-types.ts +2 -0
- package/src/helpers/component-meta.ts +93 -0
- package/src/helpers/index.ts +1 -0
- package/src/helpers/lib-entries.ts +139 -0
- package/src/helpers/package-json.ts +96 -0
- package/src/helpers/utils.ts +82 -0
- package/src/helpers/vscode-custom-data.ts +35 -0
- package/src/index.ts +29 -0
- package/src/key-generate.ts +10 -0
- package/src/lint/fix.ts +7 -0
- package/src/lint/index.ts +27 -0
- package/src/make.ts +322 -0
- package/src/migrate/database.ts +1 -0
- package/src/migrate/dns.ts +3 -0
- package/src/prepublish.ts +17 -0
- package/src/release.ts +15 -0
- package/src/start-caddy.ts +13 -0
- package/src/test/coverage.ts +5 -0
- package/src/test/feature.ts +5 -0
- package/src/test/ui.ts +5 -0
- package/src/test/unit.ts +5 -0
- package/src/test.ts +5 -0
- package/src/tinker.ts +10 -0
- package/src/typecheck.ts +5 -0
- package/src/types.ts +20 -0
- package/src/upgrade/bun.ts +4 -0
- package/src/upgrade/dependencies.ts +0 -0
- package/src/upgrade/framework.ts +30 -0
- package/src/upgrade/index.ts +21 -0
- package/src/upgrade.ts +65 -0
- package/src/zip/api.ts +22 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// import { generateMigrationFile } from '@stacksjs/database'
|
|
2
|
+
import User from '../../../../../../app/Models/User'
|
|
3
|
+
import { fieldAssociation, modelEntity } from './fields'
|
|
4
|
+
|
|
5
|
+
const file = Bun.file('user-migration.ts')
|
|
6
|
+
const writer = file.writer()
|
|
7
|
+
|
|
8
|
+
const driver = 'sqlite'
|
|
9
|
+
|
|
10
|
+
writer.write('import { Kysely, sql } from \'kysely\'\n')
|
|
11
|
+
writer.write('import { db } from \'@stacksjs/database\'\n')
|
|
12
|
+
writer.write('\n')
|
|
13
|
+
writer.write('export async function up(db: Kysely<any>): Promise<void> {\n')
|
|
14
|
+
|
|
15
|
+
writer.write(' await db.schema\n')
|
|
16
|
+
writer.write(` .createTable('${User.table}')\n`)
|
|
17
|
+
|
|
18
|
+
writer.write(' .addColumn(\'id\', \'integer\', (col) => col.primaryKey())\n')
|
|
19
|
+
|
|
20
|
+
for (let modelIndex = 0; modelIndex < modelEntity.length; modelIndex++) {
|
|
21
|
+
const modelElement = modelEntity[modelIndex]
|
|
22
|
+
|
|
23
|
+
if (!modelElement)
|
|
24
|
+
continue
|
|
25
|
+
|
|
26
|
+
let entity = ''
|
|
27
|
+
let characteristic = ''
|
|
28
|
+
|
|
29
|
+
const isNullablePresent = modelElement.fieldArray.some(item => item.entity === 'nullable')
|
|
30
|
+
|
|
31
|
+
if (modelElement.default)
|
|
32
|
+
characteristic += `.defaultTo('${modelElement.default.toString()}')`
|
|
33
|
+
|
|
34
|
+
if (modelElement.unique)
|
|
35
|
+
characteristic += '.unique()'
|
|
36
|
+
|
|
37
|
+
if (!isNullablePresent)
|
|
38
|
+
characteristic += '.notNull()'
|
|
39
|
+
|
|
40
|
+
for (let fieldIndex = 0; fieldIndex < modelElement.fieldArray.length; fieldIndex++) {
|
|
41
|
+
const fieldArrayElement = modelElement.fieldArray[fieldIndex]
|
|
42
|
+
|
|
43
|
+
if (!fieldArrayElement)
|
|
44
|
+
continue
|
|
45
|
+
|
|
46
|
+
if (!fieldAssociation[driver])
|
|
47
|
+
continue
|
|
48
|
+
|
|
49
|
+
if (fieldAssociation[driver][fieldArrayElement.entity])
|
|
50
|
+
entity += `${fieldAssociation[driver][fieldArrayElement.entity]}`
|
|
51
|
+
|
|
52
|
+
// fieldEntity.forEach((entityField) => {
|
|
53
|
+
// if (fieldArrayElement.entity === entityField)
|
|
54
|
+
// entity += `(${fieldArrayElement.charValue})`
|
|
55
|
+
// })
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
writer.write(` .addColumn('${modelElement.field}', '${entity}', (col) => col${characteristic})\n`)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
writer.write(' .addColumn(\'created_at\', \'timestamp\', (col) => col.defaultTo(sql`CURRENT_TIMESTAMP`).notNull())\n')
|
|
62
|
+
writer.write(' .execute()\n')
|
|
63
|
+
writer.write('}\n\n')
|
|
64
|
+
|
|
65
|
+
writer.write('process.exit(0)\n')
|
|
66
|
+
|
|
67
|
+
await writer.end()
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// import { generateMigrationFile } from '@stacksjs/database'
|
|
2
|
+
// import { config } from '@stacksjs/config'
|
|
3
|
+
|
|
4
|
+
// const driver = config.database.default
|
|
5
|
+
const driver = 'sqlite'
|
|
6
|
+
|
|
7
|
+
if (driver === 'sqlite')
|
|
8
|
+
await import('./migration-sqlite.js')
|
|
9
|
+
else
|
|
10
|
+
await import('./migration-mysql.js')
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import type { Kysely } from 'kysely'
|
|
3
|
+
import { sql } from 'kysely'
|
|
4
|
+
import { db } from '@stacksjs/database'
|
|
5
|
+
import { ExitCode } from '@stacksjs/types'
|
|
6
|
+
|
|
7
|
+
export async function up(db: Kysely<any>): Promise<void> {
|
|
8
|
+
await db.schema
|
|
9
|
+
.createTable('users')
|
|
10
|
+
.addColumn('id', 'integer', col => col.primaryKey())
|
|
11
|
+
.addColumn('name', 'text', col => col.defaultTo('test').notNull())
|
|
12
|
+
.addColumn('email', 'text', col => col.defaultTo('test email').unique().notNull())
|
|
13
|
+
.addColumn('password', 'text', col => col.notNull())
|
|
14
|
+
.addColumn('created_at', 'timestamp', col => col.defaultTo(sql`CURRENT_TIMESTAMP`).notNull())
|
|
15
|
+
.execute()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
await up(db)
|
|
19
|
+
|
|
20
|
+
process.exit(ExitCode.Success)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { log } from '@stacksjs/cli'
|
|
3
|
+
import { S3 } from '@aws-sdk/client-s3'
|
|
4
|
+
import { SES } from '@aws-sdk/client-ses'
|
|
5
|
+
import { ExitCode } from '@stacksjs/types'
|
|
6
|
+
|
|
7
|
+
const ses = new SES({ apiVersion: '2010-12-01' })
|
|
8
|
+
const s3 = new S3({ apiVersion: '2006-03-01' })
|
|
9
|
+
|
|
10
|
+
// oddly, this somehow does not play well within a CDK construct
|
|
11
|
+
// so we need to use the AWS SDK directly to create the rule
|
|
12
|
+
// unsure whether it's an AWS or implementation issue
|
|
13
|
+
|
|
14
|
+
// need to query S3 to get the bucket name, based on whether the name contains -email-
|
|
15
|
+
// which is indicative of the email bucket created by the CDK construct
|
|
16
|
+
let bucketName: string | undefined
|
|
17
|
+
const data = await s3.listBuckets({})
|
|
18
|
+
|
|
19
|
+
if (data.Buckets)
|
|
20
|
+
bucketName = data.Buckets.find(bucket => bucket.Name && bucket.Name.includes('-email-'))?.Name
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.log('Bucket Name:', bucketName)
|
|
24
|
+
|
|
25
|
+
if (!bucketName) {
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
27
|
+
console.log('Stacks Email Bucket not found')
|
|
28
|
+
process.exit(ExitCode.FatalError)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const params: any = {
|
|
32
|
+
Rule: {
|
|
33
|
+
Actions: [
|
|
34
|
+
{
|
|
35
|
+
S3Action: {
|
|
36
|
+
BucketName: bucketName,
|
|
37
|
+
ObjectKeyPrefix: 'tmp/email_in',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
Enabled: true,
|
|
42
|
+
Name: 'Inbound',
|
|
43
|
+
ScanEnabled: true,
|
|
44
|
+
TlsPolicy: 'Require',
|
|
45
|
+
},
|
|
46
|
+
RuleSetName: 'your-rule-set-name',
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
const data = await ses.createReceiptRule(params)
|
|
51
|
+
log.info('Success', data)
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error(error)
|
|
55
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { log, runCommand } from '@stacksjs/cli'
|
|
3
|
+
import { config } from '@stacksjs/config'
|
|
4
|
+
import { path as p } from '@stacksjs/path'
|
|
5
|
+
import { storage } from '@stacksjs/storage'
|
|
6
|
+
|
|
7
|
+
await runCommand('bun run build', {
|
|
8
|
+
cwd: p.frameworkPath(),
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
if (storage.hasFiles(p.projectPath('docs'))) {
|
|
12
|
+
await runCommand('bun run build', {
|
|
13
|
+
cwd: p.frameworkPath('docs'),
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (config.app.docMode !== true) { // when in docs mode, we disregard building views
|
|
18
|
+
await runCommand('bun run build', {
|
|
19
|
+
cwd: p.frameworkPath('views'),
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// await runCommand('bun run build-layer', {
|
|
24
|
+
// cwd: p.corePath('cloud'),
|
|
25
|
+
// })
|
|
26
|
+
|
|
27
|
+
// await runCommand('bun run build-edge', {
|
|
28
|
+
// cwd: p.corePath('cloud'),
|
|
29
|
+
// })
|
|
30
|
+
|
|
31
|
+
await runCommand('bun zip/api.ts', {
|
|
32
|
+
cwd: p.actionsPath(),
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
await runCommand('bun zip.ts', {
|
|
36
|
+
cwd: p.cloudPath(),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
log.info('Preparing Deployment...')
|
|
40
|
+
|
|
41
|
+
const profile = process.env.AWS_PROFILE || 'stacks'
|
|
42
|
+
|
|
43
|
+
// TODO: ensure we check whether cdk bootstrap needs to be run
|
|
44
|
+
await runCommand(`bunx cdk deploy --require-approval never --profile="${profile}"`, {
|
|
45
|
+
cwd: p.cloudPath(),
|
|
46
|
+
})
|
package/src/dev/api.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { path as p } from '@stacksjs/path'
|
|
2
|
+
import { log, parseOptions, runCommand } from '@stacksjs/cli'
|
|
3
|
+
import { serve } from '@stacksjs/router'
|
|
4
|
+
import { config } from '@stacksjs/config'
|
|
5
|
+
|
|
6
|
+
const options = parseOptions()
|
|
7
|
+
|
|
8
|
+
if (options.verbose)
|
|
9
|
+
log.info('Running API dev server via', `bunx vite --config ${p.vitePath('src/api.ts')}`, options)
|
|
10
|
+
|
|
11
|
+
serve({
|
|
12
|
+
port: config.app.ports?.api, // defaults to 3999
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
// the reason we start a Vite dev server next is because we need the Bun server proxied by vite
|
|
16
|
+
await runCommand(`bunx vite --config ${p.vitePath('src/api.ts')}`, {
|
|
17
|
+
// ...options,
|
|
18
|
+
cwd: p.frameworkPath(),
|
|
19
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { frameworkPath, vitePath } from '@stacksjs/path'
|
|
2
|
+
import { parseOptions, runCommand } from '@stacksjs/cli'
|
|
3
|
+
import type { DeployOptions } from '@stacksjs/types'
|
|
4
|
+
|
|
5
|
+
const options: DeployOptions = parseOptions()
|
|
6
|
+
|
|
7
|
+
if (options.verbose)
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
console.log('dev components options', options)
|
|
10
|
+
|
|
11
|
+
await runCommand(`bunx vite --config ${vitePath('src/components.ts')}`, {
|
|
12
|
+
...options,
|
|
13
|
+
cwd: frameworkPath(),
|
|
14
|
+
})
|
package/src/dev/docs.ts
ADDED
package/src/dev/index.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { log } from '@stacksjs/logging'
|
|
2
|
+
import type { DevOptions } from '@stacksjs/types'
|
|
3
|
+
import { Action } from '@stacksjs/enums'
|
|
4
|
+
import { runAction } from '../helpers'
|
|
5
|
+
|
|
6
|
+
export async function runDevServer(options: DevOptions) {
|
|
7
|
+
log.info('Starting your Frontend Engine...')
|
|
8
|
+
await runAction(Action.Dev, options)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function runFrontendDevServer(options: DevOptions) {
|
|
12
|
+
log.info('Starting your UI Engine...')
|
|
13
|
+
await runAction(Action.Dev, options)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function runBackendDevServer(options: DevOptions) {
|
|
17
|
+
runApiDevServer(options)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function runApiDevServer(options: DevOptions) {
|
|
21
|
+
log.info('Starting your API...')
|
|
22
|
+
await runAction(Action.DevApi, options)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function runComponentsDevServer(options: DevOptions) {
|
|
26
|
+
log.info('Starting your Library Engine...')
|
|
27
|
+
await runAction(Action.DevComponents, options)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function runDashboardDevServer(options: DevOptions) {
|
|
31
|
+
log.info('Starting your Dashboard...')
|
|
32
|
+
await runAction(Action.DevDashboard, options)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function runSystemTrayDevServer(options: DevOptions) {
|
|
36
|
+
log.info('Starting your System Tray...')
|
|
37
|
+
await runAction(Action.DevSystemTray, options)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function runDesktopDevServer(options: DevOptions) {
|
|
41
|
+
log.info('Starting your Desktop Engine...')
|
|
42
|
+
await runAction(Action.DevDesktop, options)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function runDocsDevServer(options: DevOptions) {
|
|
46
|
+
log.info('Starting your Docs Engine...')
|
|
47
|
+
await runAction(Action.DevDocs, options)
|
|
48
|
+
}
|
package/src/dev/views.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { createHostedZone, getNameservers, updateNameservers } from '@stacksjs/dns'
|
|
3
|
+
import { app } from '@stacksjs/config'
|
|
4
|
+
import { handleError } from '@stacksjs/error-handling'
|
|
5
|
+
import { italic, parseOptions, runCommand } from '@stacksjs/cli'
|
|
6
|
+
import { whois } from '@stacksjs/whois'
|
|
7
|
+
import { logger } from '@stacksjs/logging'
|
|
8
|
+
import { projectConfigPath } from '@stacksjs/path'
|
|
9
|
+
|
|
10
|
+
interface AddOptions {
|
|
11
|
+
domain?: string
|
|
12
|
+
verbose: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const parsedOptions = parseOptions()
|
|
16
|
+
const options: AddOptions = {
|
|
17
|
+
domain: parsedOptions.domain as string,
|
|
18
|
+
verbose: parsedOptions.verbose as boolean,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!options.domain) {
|
|
22
|
+
if (app.url) {
|
|
23
|
+
options.domain = app.url
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
handleError('there was no domain provided when')
|
|
27
|
+
process.exit(1)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const result = await createHostedZone(options.domain)
|
|
32
|
+
|
|
33
|
+
if (result.isErr()) {
|
|
34
|
+
handleError(result.error)
|
|
35
|
+
process.exit(1)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Update the nameservers
|
|
39
|
+
const nameServers = await getNameservers(options.domain)
|
|
40
|
+
|
|
41
|
+
if (!nameServers) {
|
|
42
|
+
handleError(`No nameservers found for domain: ${options.domain}. Please ensure the Hosted Zone exists in Route53.`)
|
|
43
|
+
process.exit(1)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await updateNameservers(nameServers)
|
|
47
|
+
|
|
48
|
+
const nameservers = result.value
|
|
49
|
+
const registrar: string = (await whois(options.domain, true)).parsedData.Registrar
|
|
50
|
+
|
|
51
|
+
// usually for Route53 registered domains, we don't need to update create a hosted zone as it's already
|
|
52
|
+
// done for us. But in case it's not, we still need to ensure it's created before we can deploy
|
|
53
|
+
if (registrar.includes('Amazon')) {
|
|
54
|
+
if (parsedOptions.deploy) {
|
|
55
|
+
await runCommand('buddy deploy')
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
logger.log('')
|
|
59
|
+
logger.log('You can now continue your deployment process by re-running:')
|
|
60
|
+
logger.log('')
|
|
61
|
+
logger.log(` ➡️ ${italic('buddy deploy')}`)
|
|
62
|
+
logger.log('')
|
|
63
|
+
}
|
|
64
|
+
process.exit(0)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
logger.log('')
|
|
68
|
+
logger.log('ℹ️ Please note, before continuing your deployment process,')
|
|
69
|
+
logger.log(` update your ${registrar} nameservers to the following:`)
|
|
70
|
+
|
|
71
|
+
const emojis = ['1️⃣', '2️⃣', '3️⃣', '4️⃣']
|
|
72
|
+
logger.log('')
|
|
73
|
+
nameservers.forEach((nameserver, index) => {
|
|
74
|
+
logger.log(` ${emojis[index]} Nameserver: ${nameserver}`)
|
|
75
|
+
})
|
|
76
|
+
logger.log('')
|
|
77
|
+
logger.log(italic(`stored in ${projectConfigPath('dns.ts')}`))
|
|
78
|
+
logger.log('')
|
|
79
|
+
logger.log('Once the nameservers have been updated, re-run the following command:')
|
|
80
|
+
logger.log('')
|
|
81
|
+
logger.log(` ➡️ ${italic('buddy deploy')}`)
|
|
82
|
+
logger.log('')
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { log, parseOptions } from '@stacksjs/cli'
|
|
3
|
+
import type { PurchaseOptions } from '@stacksjs/cloud'
|
|
4
|
+
import { purchaseDomain } from '@stacksjs/cloud'
|
|
5
|
+
import { config } from '@stacksjs/config'
|
|
6
|
+
import { handleError } from '@stacksjs/error-handling'
|
|
7
|
+
import { ExitCode } from '@stacksjs/types'
|
|
8
|
+
|
|
9
|
+
const c = config.dns.contactInfo
|
|
10
|
+
if (!c) {
|
|
11
|
+
handleError('You must provide contact info in your config file.')
|
|
12
|
+
process.exit(ExitCode.FatalError)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const defaultOptions: PurchaseOptions = {
|
|
16
|
+
domain: '',
|
|
17
|
+
years: 1,
|
|
18
|
+
privacy: true,
|
|
19
|
+
autoRenew: true,
|
|
20
|
+
registrantFirstName: c.firstName as string,
|
|
21
|
+
registrantLastName: c.lastName as string,
|
|
22
|
+
registrantOrganization: c.organizationName as string,
|
|
23
|
+
registrantAddressLine1: c.addressLine1 as string,
|
|
24
|
+
registrantAddressLine2: c.addressLine2 as string,
|
|
25
|
+
registrantCity: c.city as string,
|
|
26
|
+
registrantState: c.state as string,
|
|
27
|
+
registrantCountry: c.countryCode as string,
|
|
28
|
+
registrantZip: c.zip as string,
|
|
29
|
+
registrantPhone: c.phoneNumber as string,
|
|
30
|
+
registrantEmail: c.email as string,
|
|
31
|
+
adminFirstName: c.admin?.firstName || c.firstName as string,
|
|
32
|
+
adminLastName: c.admin?.lastName || c.lastName as string,
|
|
33
|
+
adminOrganization: c.admin?.organizationName || c.organizationName as string,
|
|
34
|
+
adminAddressLine1: c.admin?.addressLine1 || c.addressLine1 as string,
|
|
35
|
+
adminAddressLine2: c.admin?.addressLine2 || c.addressLine2 as string,
|
|
36
|
+
adminCity: c.admin?.city || c.city as string,
|
|
37
|
+
adminState: c.admin?.state || c.state as string,
|
|
38
|
+
adminCountry: c.admin?.countryCode || c.countryCode as string,
|
|
39
|
+
adminZip: c.admin?.zip || c.zip as string,
|
|
40
|
+
adminPhone: c.admin?.phoneNumber as string || c.phoneNumber as string,
|
|
41
|
+
adminEmail: c.admin?.email || c.email as string,
|
|
42
|
+
techFirstName: c.tech?.firstName || c.firstName as string,
|
|
43
|
+
techLastName: c.tech?.lastName || c.lastName as string,
|
|
44
|
+
techOrganization: c.tech?.organizationName || c.organizationName as string,
|
|
45
|
+
techAddressLine1: c.tech?.addressLine1 || c.addressLine1 as string,
|
|
46
|
+
techAddressLine2: c.tech?.addressLine2 || c.addressLine2 as string,
|
|
47
|
+
techCity: c.tech?.city || c.city as string,
|
|
48
|
+
techState: c.tech?.state || c.state as string,
|
|
49
|
+
techCountry: c.tech?.countryCode || c.countryCode as string,
|
|
50
|
+
techZip: c.tech?.zip || c.zip as string,
|
|
51
|
+
techPhone: c.tech?.phoneNumber as string || c.phoneNumber as string,
|
|
52
|
+
techEmail: c.tech?.email || c.email as string,
|
|
53
|
+
privacyAdmin: c.privacyAdmin || c.privacy || true,
|
|
54
|
+
privacyTech: c.privacyTech || c.privacy || true,
|
|
55
|
+
privacyRegistrant: c.privacyRegistrant || c.privacy || true,
|
|
56
|
+
contactType: 'person',
|
|
57
|
+
verbose: false,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const options: PurchaseOptions = { ...defaultOptions, ...parseOptions() }
|
|
61
|
+
|
|
62
|
+
if (!options.domain) {
|
|
63
|
+
handleError('You must provide a domain name to purchase.')
|
|
64
|
+
process.exit(ExitCode.FatalError)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const result = purchaseDomain(options.domain, options)
|
|
68
|
+
|
|
69
|
+
if (result.isErr()) {
|
|
70
|
+
handleError(result.error)
|
|
71
|
+
process.exit(ExitCode.FatalError)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
log.info('Domain purchased successfully.')
|
|
75
|
+
|
|
76
|
+
process.exit(ExitCode.Success)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { handleError } from '@stacksjs/error-handling'
|
|
3
|
+
import { logger } from '@stacksjs/logging'
|
|
4
|
+
import { deleteHostedZoneRecords } from '@stacksjs/dns'
|
|
5
|
+
import { app } from '@stacksjs/config'
|
|
6
|
+
import { parseOptions } from '@stacksjs/cli'
|
|
7
|
+
|
|
8
|
+
interface RemoveOptions {
|
|
9
|
+
domain?: string
|
|
10
|
+
verbose: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const parsedOptions = parseOptions()
|
|
14
|
+
const options: RemoveOptions = {
|
|
15
|
+
domain: parsedOptions.domain as string,
|
|
16
|
+
verbose: parsedOptions.verbose as boolean,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!options.domain) {
|
|
20
|
+
if (app.url) {
|
|
21
|
+
options.domain = app.url
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
handleError('there was no domain provided when')
|
|
25
|
+
process.exit(1)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (options.verbose)
|
|
30
|
+
logger.log(`Removing domain: ${options.domain}`)
|
|
31
|
+
|
|
32
|
+
// const result = await deleteHostedZone(options.domain)
|
|
33
|
+
const result = await deleteHostedZoneRecords(options.domain)
|
|
34
|
+
|
|
35
|
+
if (result.isErr()) {
|
|
36
|
+
handleError(result.error)
|
|
37
|
+
process.exit(1)
|
|
38
|
+
}
|
package/src/examples.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { log } from '@stacksjs/logging'
|
|
3
|
+
import { hasComponents } from '@stacksjs/storage'
|
|
4
|
+
import { runNpmScript } from '@stacksjs/utils'
|
|
5
|
+
import type { ExamplesOptions } from '@stacksjs/types'
|
|
6
|
+
import { ExitCode } from '@stacksjs/types'
|
|
7
|
+
import { NpmScript } from '@stacksjs/enums'
|
|
8
|
+
|
|
9
|
+
export async function invoke(options: ExamplesOptions) {
|
|
10
|
+
if (options.components || options.vue)
|
|
11
|
+
await componentExample(options)
|
|
12
|
+
|
|
13
|
+
else if (options.webComponents || options.elements)
|
|
14
|
+
await webComponentExample(options)
|
|
15
|
+
|
|
16
|
+
else
|
|
17
|
+
log.error('An unsupported option was used. Please try again, check the documentation & report the issue, if needed.')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function examples(options: ExamplesOptions) {
|
|
21
|
+
return invoke(options)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function componentExample(options: ExamplesOptions) {
|
|
25
|
+
if (hasComponents()) {
|
|
26
|
+
await runNpmScript(NpmScript.ExampleVue, options)
|
|
27
|
+
log.success('Your component library was built successfully')
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
log.info('No components found.')
|
|
31
|
+
// todo: throw custom error here
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function webComponentExample(options: ExamplesOptions) {
|
|
36
|
+
if (hasComponents()) {
|
|
37
|
+
log.info('Building your Web Component library...')
|
|
38
|
+
await runNpmScript(NpmScript.BuildWebComponents, options)
|
|
39
|
+
log.success('Your Web Component library was built successfully')
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
log.info('No components found.')
|
|
43
|
+
// todo: throw custom error here
|
|
44
|
+
process.exit(ExitCode.FatalError)
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/fresh.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import process from 'node:process'
|
|
2
|
+
import { ExitCode } from '@stacksjs/types'
|
|
3
|
+
import { runCommand } from '@stacksjs/cli'
|
|
4
|
+
import { logger } from '@stacksjs/logging'
|
|
5
|
+
import { projectPath } from '@stacksjs/path'
|
|
6
|
+
import { cleanProject } from '@stacksjs/utils'
|
|
7
|
+
|
|
8
|
+
logger.log('Cleaning project...')
|
|
9
|
+
await cleanProject()
|
|
10
|
+
|
|
11
|
+
logger.log('Installing dependencies...')
|
|
12
|
+
|
|
13
|
+
const result = await runCommand('bun install', {
|
|
14
|
+
cwd: projectPath(),
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
if (result.isErr()) {
|
|
18
|
+
handleError(result.error)
|
|
19
|
+
process.exit(ExitCode.FatalError)
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// TODO: generate Caddyfile for the core app
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This action generates the component meta.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { log } from '@stacksjs/logging'
|
|
8
|
+
import { hasComponents } from '@stacksjs/storage'
|
|
9
|
+
import { generateComponentMeta } from '../helpers/component-meta'
|
|
10
|
+
|
|
11
|
+
log.info('Generating component meta...')
|
|
12
|
+
|
|
13
|
+
if (hasComponents())
|
|
14
|
+
generateComponentMeta()
|
|
15
|
+
|
|
16
|
+
else
|
|
17
|
+
log.info('No components found. Skipping component meta generation.')
|
|
18
|
+
|
|
19
|
+
log.success('Generated component meta.')
|