tsoft-cli 2.0.0 → 2.0.5
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/README.md +29 -94
- package/{packages/theme/bin → bin}/run.js +2 -0
- package/package.json +45 -6
- package/.editorconfig +0 -11
- package/.github/workflows/node.js.yml +0 -25
- package/.nvmrc +0 -1
- package/.prettierrc.json +0 -8
- package/.vscode/extensions.json +0 -3
- package/.vscode/settings.json +0 -4
- package/CHANGELOG.md +0 -113
- package/packages/cli/README.md +0 -53
- package/packages/cli/bin/dev.js +0 -5
- package/packages/cli/bin/run.cmd +0 -3
- package/packages/cli/bin/run.js +0 -5
- package/packages/cli/enums.ts +0 -4
- package/packages/cli/index.ts +0 -11
- package/packages/cli/package.json +0 -59
- package/packages/cli/tsconfig.json +0 -9
- package/packages/shared/index.ts +0 -6
- package/packages/shared/package.json +0 -45
- package/packages/shared/src/cli-progress.ts +0 -3
- package/packages/shared/src/commands/cli-all-commands.ts +0 -6
- package/packages/shared/src/commands/version-command.ts +0 -12
- package/packages/shared/src/consola.ts +0 -1
- package/packages/shared/src/open.ts +0 -3
- package/packages/shared/src/unzip.ts +0 -15
- package/packages/shared/tsconfig.json +0 -9
- package/packages/theme/bin/dev.js +0 -5
- package/packages/theme/bin/run.cmd +0 -3
- package/packages/theme/index.ts +0 -21
- package/packages/theme/jest.config.ts +0 -3
- package/packages/theme/package.json +0 -66
- package/packages/theme/src/commands/theme/create.ts +0 -51
- package/packages/theme/src/commands/theme/delete-site.ts +0 -30
- package/packages/theme/src/commands/theme/delete-theme.ts +0 -39
- package/packages/theme/src/commands/theme/dev.ts +0 -47
- package/packages/theme/src/commands/theme/pull.ts +0 -26
- package/packages/theme/src/enums.ts +0 -55
- package/packages/theme/src/services/ClientCredentials.ts +0 -127
- package/packages/theme/src/services/Constants.ts +0 -19
- package/packages/theme/src/services/CreateTheme.ts +0 -88
- package/packages/theme/src/services/DeleteSite.ts +0 -30
- package/packages/theme/src/services/DeleteTheme.ts +0 -46
- package/packages/theme/src/services/FileManager.ts +0 -62
- package/packages/theme/src/services/Request.ts +0 -18
- package/packages/theme/src/services/StartTheme.ts +0 -363
- package/packages/theme/src/services/SyncTheme.ts +0 -108
- package/packages/theme/src/services/ThemeManager.ts +0 -118
- package/packages/theme/src/services/Tsoft.ts +0 -151
- package/packages/theme/src/services/types.ts +0 -90
- package/packages/theme/src/types.ts +0 -20
- package/packages/theme/src/utils/screen.ts +0 -28
- package/packages/theme/src/utils/utils.ts +0 -83
- package/packages/theme/tests/FileManager.test.js +0 -90
- package/packages/theme/tsconfig.json +0 -9
- package/pnpm-workspace.yaml +0 -2
- package/pull_request_template.md +0 -5
- package/scripts/prebuild.js +0 -45
- package/scripts/versions.js +0 -70
- package/tsconfig.build.json +0 -21
package/packages/theme/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { CLIAllCommands, VersionCommand } from '@tsoft-cli/shared'
|
|
2
|
-
import ThemeCreate from './src/commands/theme/create.js'
|
|
3
|
-
import ThemeDev from './src/commands/theme/dev.js'
|
|
4
|
-
import ThemePull from './src/commands/theme/pull.js'
|
|
5
|
-
import ThemeDeleteSite from './src/commands/theme/delete-site.js'
|
|
6
|
-
import ThemeDeleteTheme from './src/commands/theme/delete-theme.js'
|
|
7
|
-
import { packageJson } from './src/enums.js'
|
|
8
|
-
|
|
9
|
-
VersionCommand.version = packageJson.version
|
|
10
|
-
|
|
11
|
-
export const COMMANDS = {
|
|
12
|
-
[CLIAllCommands.cliTopic]: CLIAllCommands,
|
|
13
|
-
[VersionCommand.cliTopic]: VersionCommand,
|
|
14
|
-
[`theme:${ThemeCreate.cliTopic}`]: ThemeCreate,
|
|
15
|
-
[`theme:${ThemeDev.cliTopic}`]: ThemeDev,
|
|
16
|
-
[`theme:${ThemePull.cliTopic}`]: ThemePull,
|
|
17
|
-
[`theme:${ThemeDeleteSite.cliTopic}`]: ThemeDeleteSite,
|
|
18
|
-
[`theme:${ThemeDeleteTheme.cliTopic}`]: ThemeDeleteTheme,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default COMMANDS
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tsoft-cli/theme",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "A theme development cli for developers who want to create themes for T-Soft.",
|
|
5
|
-
"author": "T-Soft",
|
|
6
|
-
"license": "ISC",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "/build/index.js",
|
|
9
|
-
"types": "/build/index.d.ts",
|
|
10
|
-
"bin": {
|
|
11
|
-
"tsoft-theme": "./bin/run.js"
|
|
12
|
-
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "tsc",
|
|
15
|
-
"test": "jest"
|
|
16
|
-
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@inquirer/prompts": "^5.5.0",
|
|
19
|
-
"@oclif/core": "4.0.21",
|
|
20
|
-
"@tsoft-cli/shared": "1.0.0",
|
|
21
|
-
"axios": "^1.7.7",
|
|
22
|
-
"chokidar": "^3.6.0",
|
|
23
|
-
"figlet": "^1.7.0"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"@types/figlet": "^1.5.8",
|
|
27
|
-
"@types/node": "^22.5.2",
|
|
28
|
-
"jest": "^29.7.0",
|
|
29
|
-
"mock-fs": "^5.2.0",
|
|
30
|
-
"ts-node": "^10.9.2",
|
|
31
|
-
"typescript": "^5.5.4"
|
|
32
|
-
},
|
|
33
|
-
"oclif": {
|
|
34
|
-
"bin": "tsoft-theme",
|
|
35
|
-
"commands": {
|
|
36
|
-
"strategy": "explicit",
|
|
37
|
-
"target": "./build/index.js",
|
|
38
|
-
"identifier": "COMMANDS"
|
|
39
|
-
},
|
|
40
|
-
"dirname": "tsoft-theme",
|
|
41
|
-
"topicSeparator": " ",
|
|
42
|
-
"topics": {
|
|
43
|
-
"theme": {
|
|
44
|
-
"description": "Tema işlemleri"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"files": [
|
|
49
|
-
"bin",
|
|
50
|
-
"build"
|
|
51
|
-
],
|
|
52
|
-
"exports": {
|
|
53
|
-
".": {
|
|
54
|
-
"import": "./build/index.js",
|
|
55
|
-
"types": "./build/index.d.ts"
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"engines": {
|
|
59
|
-
"node": ">= 18"
|
|
60
|
-
},
|
|
61
|
-
"homepage": "https://github.com/tekrom/tsoft-cli/tree/main/packages/theme",
|
|
62
|
-
"repository": {
|
|
63
|
-
"type": "git",
|
|
64
|
-
"url": "git+https://github.com/tekrom/tsoft-cli.git"
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core'
|
|
2
|
-
import { consola } from '@tsoft-cli/shared'
|
|
3
|
-
import { CreateTheme } from '../../services/CreateTheme.js'
|
|
4
|
-
import { getLocalSites, saveThemeData, saveThemeTxt, slugify } from '../../utils/utils.js'
|
|
5
|
-
import { clearScreen, displayAsciiArt } from '../../utils/screen.js'
|
|
6
|
-
import { StartTheme } from '../../services/StartTheme.js'
|
|
7
|
-
import { Tsoft } from '../../services/Tsoft.js'
|
|
8
|
-
import { menuSelections } from '../../enums.js'
|
|
9
|
-
|
|
10
|
-
export default class ThemeCreate extends Command {
|
|
11
|
-
static cliTopic = menuSelections.create.cliTopic
|
|
12
|
-
static override description = menuSelections.create.description
|
|
13
|
-
|
|
14
|
-
public async run(): Promise<void> {
|
|
15
|
-
await this.parse(ThemeCreate)
|
|
16
|
-
|
|
17
|
-
clearScreen()
|
|
18
|
-
await displayAsciiArt()
|
|
19
|
-
|
|
20
|
-
const createCommand = new CreateTheme()
|
|
21
|
-
const sites = getLocalSites()
|
|
22
|
-
const siteName = await createCommand.selectSite(sites)
|
|
23
|
-
if (!siteName) {
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const { themeName, author, version } = await createCommand.getThemeDetails()
|
|
28
|
-
const themeNameSlug = slugify(themeName)
|
|
29
|
-
const themePath = await createCommand.createThemeDirectory(siteName, themeNameSlug)
|
|
30
|
-
saveThemeTxt(themePath, {
|
|
31
|
-
site: siteName,
|
|
32
|
-
name: themeName,
|
|
33
|
-
author: author,
|
|
34
|
-
version: version,
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
clearScreen()
|
|
38
|
-
consola.success(`Tema '${themeName}' başarıyla oluşturuldu.`)
|
|
39
|
-
|
|
40
|
-
const tsoft = new Tsoft(siteName)
|
|
41
|
-
const startTheme = new StartTheme(tsoft)
|
|
42
|
-
await startTheme.start(themeNameSlug, true)
|
|
43
|
-
|
|
44
|
-
saveThemeData(themePath, {
|
|
45
|
-
site: siteName,
|
|
46
|
-
name: themeName,
|
|
47
|
-
author: author,
|
|
48
|
-
version: version,
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core'
|
|
2
|
-
import { consola } from '@tsoft-cli/shared'
|
|
3
|
-
import { menuSelections } from '../../enums.js'
|
|
4
|
-
import { DeleteSite } from '../../services/DeleteSite.js'
|
|
5
|
-
import { clearScreen, displayAsciiArt } from '../../utils/screen.js'
|
|
6
|
-
import { getDirectories } from '../../utils/utils.js'
|
|
7
|
-
|
|
8
|
-
export default class ThemeDeleteSite extends Command {
|
|
9
|
-
static cliTopic = menuSelections.deleteSite.cliTopic
|
|
10
|
-
static override description = menuSelections.deleteSite.description
|
|
11
|
-
|
|
12
|
-
public async run(): Promise<void> {
|
|
13
|
-
await this.parse(ThemeDeleteSite)
|
|
14
|
-
|
|
15
|
-
clearScreen()
|
|
16
|
-
await displayAsciiArt()
|
|
17
|
-
|
|
18
|
-
const sites = getDirectories(process.cwd())
|
|
19
|
-
if (!sites.length) {
|
|
20
|
-
consola.info('Silinecek site bulunamadı.')
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const deleteTheme = new DeleteSite()
|
|
25
|
-
await deleteTheme.selectSite(sites)
|
|
26
|
-
await deleteTheme.deleteSiteFiles()
|
|
27
|
-
|
|
28
|
-
consola.success('Site silindi.')
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import { Command } from '@oclif/core'
|
|
3
|
-
import { consola } from '@tsoft-cli/shared'
|
|
4
|
-
import { menuSelections } from '../../enums.js'
|
|
5
|
-
import { DeleteTheme } from '../../services/DeleteTheme.js'
|
|
6
|
-
import { clearScreen, displayAsciiArt } from '../../utils/screen.js'
|
|
7
|
-
import { getDirectories, getThemesFromFolder } from '../../utils/utils.js'
|
|
8
|
-
|
|
9
|
-
export default class ThemeDeleteTheme extends Command {
|
|
10
|
-
static cliTopic = menuSelections.deleteTheme.cliTopic
|
|
11
|
-
static override description = menuSelections.deleteTheme.description
|
|
12
|
-
|
|
13
|
-
public async run(): Promise<void> {
|
|
14
|
-
await this.parse(ThemeDeleteTheme)
|
|
15
|
-
|
|
16
|
-
clearScreen()
|
|
17
|
-
await displayAsciiArt()
|
|
18
|
-
|
|
19
|
-
const sites = getDirectories(process.cwd())
|
|
20
|
-
if (!sites.length) {
|
|
21
|
-
consola.info('Silinecek site bulunamadı.')
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const deleteTheme = new DeleteTheme()
|
|
26
|
-
await deleteTheme.selectSite(sites)
|
|
27
|
-
|
|
28
|
-
const themes = getThemesFromFolder(path.join(process.cwd(), deleteTheme.getSiteName))
|
|
29
|
-
if (!themes.length) {
|
|
30
|
-
consola.info('Silinecek tema bulunamadı.')
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
await deleteTheme.selectTheme(themes)
|
|
35
|
-
await deleteTheme.deleteThemeFiles()
|
|
36
|
-
|
|
37
|
-
consola.success('Tema silindi.')
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core'
|
|
2
|
-
import { consola } from '@tsoft-cli/shared'
|
|
3
|
-
import { select } from '@inquirer/prompts'
|
|
4
|
-
import { StartTheme } from '../../services/StartTheme.js'
|
|
5
|
-
import { menuSelections } from '../../enums.js'
|
|
6
|
-
import { getLocalSites, getFolderFromCWD, getThemesFromFolder } from '../../utils/utils.js'
|
|
7
|
-
import { clearScreen, displayAsciiArt } from '../../utils/screen.js'
|
|
8
|
-
import { Tsoft } from '../../services/Tsoft.js'
|
|
9
|
-
|
|
10
|
-
export default class ThemeDev extends Command {
|
|
11
|
-
static cliTopic = menuSelections.dev.cliTopic
|
|
12
|
-
static override description = menuSelections.dev.description
|
|
13
|
-
|
|
14
|
-
public async run(): Promise<void> {
|
|
15
|
-
await this.parse(ThemeDev)
|
|
16
|
-
|
|
17
|
-
clearScreen()
|
|
18
|
-
await displayAsciiArt()
|
|
19
|
-
|
|
20
|
-
const sites = getLocalSites()
|
|
21
|
-
|
|
22
|
-
if (sites.length === 0) {
|
|
23
|
-
consola.error('Mevcut dizinde site bulunamadı.')
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const selectedSite = (await select({
|
|
28
|
-
message: 'Bir site seçin:',
|
|
29
|
-
choices: sites,
|
|
30
|
-
})) as string
|
|
31
|
-
const themes = getThemesFromFolder(getFolderFromCWD(selectedSite))
|
|
32
|
-
|
|
33
|
-
if (themes.length === 0) {
|
|
34
|
-
consola.error('Seçilen site dizininde tema bulunamadı.')
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const selectedTheme = (await select({
|
|
39
|
-
message: 'Bir tema seçin:',
|
|
40
|
-
choices: themes,
|
|
41
|
-
})) as string
|
|
42
|
-
|
|
43
|
-
const tsoft = new Tsoft(selectedSite)
|
|
44
|
-
const startTheme = new StartTheme(tsoft)
|
|
45
|
-
await startTheme.start(selectedTheme)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core'
|
|
2
|
-
import { menuSelections } from '../../enums.js'
|
|
3
|
-
import { CreateTheme } from '../../services/CreateTheme.js'
|
|
4
|
-
import { SyncTheme } from '../../services/SyncTheme.js'
|
|
5
|
-
import { clearScreen, displayAsciiArt } from '../../utils/screen.js'
|
|
6
|
-
import { Tsoft } from '../../services/Tsoft.js'
|
|
7
|
-
import { getDirectories } from '../../utils/utils.js'
|
|
8
|
-
|
|
9
|
-
export default class ThemePull extends Command {
|
|
10
|
-
static cliTopic = menuSelections.pull.cliTopic
|
|
11
|
-
static override description = menuSelections.pull.description
|
|
12
|
-
|
|
13
|
-
public async run(): Promise<void> {
|
|
14
|
-
await this.parse(ThemePull)
|
|
15
|
-
|
|
16
|
-
clearScreen()
|
|
17
|
-
await displayAsciiArt()
|
|
18
|
-
|
|
19
|
-
const sites = getDirectories(process.cwd())
|
|
20
|
-
const createTheme = new CreateTheme()
|
|
21
|
-
const selectedSite = await createTheme.selectSite(sites)
|
|
22
|
-
const tsoft = new Tsoft(selectedSite)
|
|
23
|
-
const syncTheme = new SyncTheme(tsoft, createTheme)
|
|
24
|
-
await syncTheme.start()
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
|
|
4
|
-
export const packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8'))
|
|
5
|
-
|
|
6
|
-
export const themeTypes = {
|
|
7
|
-
default: 'default',
|
|
8
|
-
none: 'none',
|
|
9
|
-
} as const
|
|
10
|
-
|
|
11
|
-
export const themeFileNames = {
|
|
12
|
-
tsoft: '.tsoft',
|
|
13
|
-
theme: '.theme',
|
|
14
|
-
env: '.env',
|
|
15
|
-
themeZip: 'theme.zip',
|
|
16
|
-
themeTxt: 'theme.txt',
|
|
17
|
-
} as const
|
|
18
|
-
|
|
19
|
-
export const menuSelections = {
|
|
20
|
-
create: {
|
|
21
|
-
cliTopic: 'create',
|
|
22
|
-
description: 'Yeni bir tema oluştur',
|
|
23
|
-
},
|
|
24
|
-
dev: {
|
|
25
|
-
cliTopic: 'dev',
|
|
26
|
-
description: 'Geliştirme ortamını başlat',
|
|
27
|
-
},
|
|
28
|
-
pull: {
|
|
29
|
-
cliTopic: 'pull',
|
|
30
|
-
description: 'Uzak sunucudan dosyaları indir',
|
|
31
|
-
},
|
|
32
|
-
deleteSite: {
|
|
33
|
-
cliTopic: 'delete-site',
|
|
34
|
-
description: 'Site sil',
|
|
35
|
-
},
|
|
36
|
-
deleteTheme: {
|
|
37
|
-
cliTopic: 'delete-theme',
|
|
38
|
-
description: 'Sitenin temasını sil',
|
|
39
|
-
},
|
|
40
|
-
} as const
|
|
41
|
-
|
|
42
|
-
export const allowedExtensions = [
|
|
43
|
-
'theme',
|
|
44
|
-
'twig',
|
|
45
|
-
'css',
|
|
46
|
-
'js',
|
|
47
|
-
'md',
|
|
48
|
-
'json',
|
|
49
|
-
'svg',
|
|
50
|
-
'jpeg',
|
|
51
|
-
'jpg',
|
|
52
|
-
'png',
|
|
53
|
-
'gif',
|
|
54
|
-
'webp',
|
|
55
|
-
] as const
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { consola } from '@tsoft-cli/shared'
|
|
2
|
-
import { Request } from './Request.js'
|
|
3
|
-
import type {
|
|
4
|
-
TAuthApplication,
|
|
5
|
-
TAuthMeResponse,
|
|
6
|
-
TAuthorizeResponse,
|
|
7
|
-
TClientCredentialsGetEnvironment,
|
|
8
|
-
TClientCredentialsRecoveryData,
|
|
9
|
-
TClientCredentialsRecoveryResponse,
|
|
10
|
-
} from './types.js'
|
|
11
|
-
|
|
12
|
-
export class ClientCredentials {
|
|
13
|
-
public site: string
|
|
14
|
-
public clientId: string
|
|
15
|
-
public clientSecret: string
|
|
16
|
-
public bearer: string
|
|
17
|
-
|
|
18
|
-
constructor(site: string) {
|
|
19
|
-
this.site = site
|
|
20
|
-
this.clientId = null
|
|
21
|
-
this.clientSecret = null
|
|
22
|
-
this.bearer = null
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
setClientId(clientId: string) {
|
|
26
|
-
this.clientId = clientId
|
|
27
|
-
return this
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
setClientSecret(clientSecret: string) {
|
|
31
|
-
this.clientSecret = clientSecret
|
|
32
|
-
return this
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getEnvironment(): TClientCredentialsGetEnvironment {
|
|
36
|
-
return {
|
|
37
|
-
site: this.site,
|
|
38
|
-
clientId: this.clientId,
|
|
39
|
-
clientSecret: this.clientSecret,
|
|
40
|
-
bearer: this.bearer,
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async register(CLIENT_UUID: string, clientConfiguration: { name?: string; author?: string; version?: string } = {}) {
|
|
45
|
-
const result = (await Request.request(this.site, 'api/v3/admin/auth/auth-application', {
|
|
46
|
-
method: 'POST',
|
|
47
|
-
headers: {
|
|
48
|
-
'Content-Type': 'application/json',
|
|
49
|
-
Accept: 'application/json',
|
|
50
|
-
},
|
|
51
|
-
data: {
|
|
52
|
-
uuid: CLIENT_UUID,
|
|
53
|
-
configuration: {
|
|
54
|
-
name: clientConfiguration.name,
|
|
55
|
-
author: clientConfiguration.author,
|
|
56
|
-
version: clientConfiguration.version,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
})) as TAuthApplication
|
|
60
|
-
|
|
61
|
-
if (result.status === true) {
|
|
62
|
-
this.clientId = result.data.public_key
|
|
63
|
-
return true
|
|
64
|
-
} else {
|
|
65
|
-
return false
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async authorize(): Promise<TAuthorizeResponse> {
|
|
70
|
-
return Request.request(this.site, 'api/v3/admin/auth/auth-application/authorize', {
|
|
71
|
-
method: 'POST',
|
|
72
|
-
headers: {
|
|
73
|
-
'Content-Type': 'application/json',
|
|
74
|
-
Accept: 'application/json',
|
|
75
|
-
},
|
|
76
|
-
data: {
|
|
77
|
-
public_key: this.clientId,
|
|
78
|
-
secret: this.clientSecret,
|
|
79
|
-
},
|
|
80
|
-
})
|
|
81
|
-
.then((result: TAuthorizeResponse) => {
|
|
82
|
-
if (result.status === true) {
|
|
83
|
-
this.bearer = result.data.token.plainTextToken
|
|
84
|
-
return result
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return null
|
|
88
|
-
})
|
|
89
|
-
.catch((error) => {
|
|
90
|
-
consola.error(error.message)
|
|
91
|
-
return null
|
|
92
|
-
})
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async validateToken(token: string): Promise<boolean> {
|
|
96
|
-
const response = (await Request.request(this.site, 'api/v3/admin/auth/me', {
|
|
97
|
-
method: 'POST',
|
|
98
|
-
headers: {
|
|
99
|
-
Authorization: `Bearer ${token}`,
|
|
100
|
-
},
|
|
101
|
-
data: {
|
|
102
|
-
_method: 'GET',
|
|
103
|
-
},
|
|
104
|
-
})) as TAuthMeResponse
|
|
105
|
-
|
|
106
|
-
return response.message === 'ok'
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async recovery(token: string): Promise<TClientCredentialsRecoveryData> {
|
|
110
|
-
const response = (await Request.request(this.site, `api/v3/admin/auth/auth-application/recovery/${token}`, {
|
|
111
|
-
method: 'POST',
|
|
112
|
-
})) as TClientCredentialsRecoveryResponse
|
|
113
|
-
|
|
114
|
-
if (response.status) {
|
|
115
|
-
return {
|
|
116
|
-
secret: response.data.secret,
|
|
117
|
-
public_key: response.data.public_key,
|
|
118
|
-
}
|
|
119
|
-
} else if (response?.throttle) {
|
|
120
|
-
const { limit, retryAfter, resetDate } = response.throttle
|
|
121
|
-
throw new Error(
|
|
122
|
-
`Çok fazla deneme yapıldı. Lütfen ${retryAfter} saniye sonra tekrar deneyin. Limit: ${limit}, Reset Zamanı: ${resetDate}`,
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
return null
|
|
126
|
-
}
|
|
127
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ClientCredentials } from './ClientCredentials.js'
|
|
2
|
-
|
|
3
|
-
const handleAuthorization = async (credentialHandler: ClientCredentials) => {
|
|
4
|
-
await credentialHandler.authorize()
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const Constants = Object.freeze({
|
|
8
|
-
INITIALIZE: {
|
|
9
|
-
type: 'input',
|
|
10
|
-
name: 'site',
|
|
11
|
-
message: 'Lütfen site adresini giriniz (örnek: https://tsoft.com.tr):',
|
|
12
|
-
},
|
|
13
|
-
APPROVAL: {
|
|
14
|
-
type: 'input',
|
|
15
|
-
name: 'approval',
|
|
16
|
-
message: 'Parolanızı giriniz (Lütfen panelden onaylayınız):',
|
|
17
|
-
handler: handleAuthorization,
|
|
18
|
-
},
|
|
19
|
-
})
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import { select, input } from '@inquirer/prompts'
|
|
4
|
-
import { consola } from '@tsoft-cli/shared'
|
|
5
|
-
import { ThemeManager } from './ThemeManager.js'
|
|
6
|
-
import { menuSelections, themeFileNames } from '../enums.js'
|
|
7
|
-
import { getFolderFromCWD } from '../utils/utils.js'
|
|
8
|
-
|
|
9
|
-
export class CreateTheme {
|
|
10
|
-
async selectSite(sites: string[]): Promise<string> {
|
|
11
|
-
const siteChoices = [...sites, menuSelections.create.description]
|
|
12
|
-
const selectedSite = (await select({
|
|
13
|
-
message: 'Çalışmak istediğiniz sitenin adı:',
|
|
14
|
-
choices: siteChoices,
|
|
15
|
-
})) as string
|
|
16
|
-
|
|
17
|
-
if (selectedSite == menuSelections.create.description) {
|
|
18
|
-
const result = await this.createNewSite()
|
|
19
|
-
return result
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return selectedSite
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async createNewSite() {
|
|
26
|
-
const siteName = await input({
|
|
27
|
-
message: 'Yeni site adı:',
|
|
28
|
-
required: true,
|
|
29
|
-
})
|
|
30
|
-
const themeManager = new ThemeManager(siteName)
|
|
31
|
-
const isValid = await this.validateSiteName(themeManager)
|
|
32
|
-
return isValid ? siteName : ''
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async validateSiteName(themeManager: ThemeManager) {
|
|
36
|
-
try {
|
|
37
|
-
const isValid = await themeManager.checkSiteValidity()
|
|
38
|
-
if (!isValid) {
|
|
39
|
-
consola.error('Geçersiz site adı. Lütfen geçerli bir site adı girin.')
|
|
40
|
-
return false
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return true
|
|
44
|
-
} catch (error) {
|
|
45
|
-
consola.error('Site doğrulaması sırasında hata oluştu:', error)
|
|
46
|
-
return false
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async getThemeDetails() {
|
|
51
|
-
const themeName = await input({
|
|
52
|
-
message: 'Tema adı:',
|
|
53
|
-
required: true,
|
|
54
|
-
})
|
|
55
|
-
const author = await input({
|
|
56
|
-
message: 'Author (isteğe bağlı):',
|
|
57
|
-
default: '-',
|
|
58
|
-
})
|
|
59
|
-
const version = await input({
|
|
60
|
-
message: 'Version (isteğe bağlı, varsayılan 1.0.0):',
|
|
61
|
-
default: '1.0.0',
|
|
62
|
-
required: true,
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
themeName,
|
|
67
|
-
author,
|
|
68
|
-
version,
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async createThemeDirectory(siteName: string, themeName: string) {
|
|
73
|
-
//Create named theme folder
|
|
74
|
-
const themePath = getFolderFromCWD(siteName, themeName)
|
|
75
|
-
if (!fs.existsSync(themePath)) {
|
|
76
|
-
fs.mkdirSync(themePath, { recursive: true })
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
//.tsoft file create if no exist
|
|
80
|
-
const sitePath = getFolderFromCWD(siteName)
|
|
81
|
-
const tsoftFilePath = path.join(sitePath, themeFileNames.tsoft)
|
|
82
|
-
if (!fs.existsSync(tsoftFilePath)) {
|
|
83
|
-
fs.writeFileSync(tsoftFilePath, '')
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return themePath
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import { select } from '@inquirer/prompts'
|
|
4
|
-
|
|
5
|
-
export class DeleteSite {
|
|
6
|
-
private siteName: string
|
|
7
|
-
|
|
8
|
-
public get getSiteName(): string {
|
|
9
|
-
return this.siteName
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public async selectSite(sites: string[]): Promise<void> {
|
|
13
|
-
this.siteName = (await select({
|
|
14
|
-
message: 'Siteyi seçiniz',
|
|
15
|
-
choices: sites,
|
|
16
|
-
})) as string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public async deleteSiteFiles(): Promise<void> {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
fs.rm(path.join(process.cwd(), this.siteName), { recursive: true, force: true }, (err) => {
|
|
22
|
-
if (err) {
|
|
23
|
-
return reject(err)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return resolve()
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
3
|
-
import { select } from '@inquirer/prompts'
|
|
4
|
-
|
|
5
|
-
export class DeleteTheme {
|
|
6
|
-
private siteName: string
|
|
7
|
-
private themeName: string
|
|
8
|
-
|
|
9
|
-
public get getSiteName(): string {
|
|
10
|
-
return this.siteName
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public get getThemeName(): string {
|
|
14
|
-
return this.themeName
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async selectSite(sites: string[]): Promise<void> {
|
|
18
|
-
this.siteName = (await select({
|
|
19
|
-
message: 'Siteyi seçiniz',
|
|
20
|
-
choices: sites,
|
|
21
|
-
})) as string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async selectTheme(themes: string[]): Promise<void> {
|
|
25
|
-
this.themeName = (await select({
|
|
26
|
-
message: 'Temayı seçiniz',
|
|
27
|
-
choices: themes,
|
|
28
|
-
})) as string
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async deleteThemeFiles(): Promise<void> {
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
fs.rm(
|
|
34
|
-
path.join(process.cwd(), `./${this.getSiteName}/${this.getThemeName}`),
|
|
35
|
-
{ recursive: true, force: true },
|
|
36
|
-
(err) => {
|
|
37
|
-
if (err) {
|
|
38
|
-
return reject(err)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return resolve()
|
|
42
|
-
},
|
|
43
|
-
)
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
}
|