Skip to content

Commit d955b8e

Browse files
committed
wip: rename
1 parent d3240df commit d955b8e

File tree

241 files changed

+2880
-5795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+2880
-5795
lines changed

.pnpmfile.cjs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
// const fs = require('node:fs')
22
// const path = require('node:path')
33

4-
// const exists = fs.existsSync(path.join(process.cwd(), '../factor/package.json'))
4+
// const exists = fs.existsSync(path.join(process.cwd(), '../fiction/package.json'))
55
// const localInstall = process.env.INSTALL_ENV === 'local'
6-
function rewriteFactorDependency(deps) {
6+
function rewriteFictionDependency(deps) {
77
// Object.entries(deps).forEach(([name, version]) => {
88
// if (name.includes("@fiction")) {
99
// deps[name] =
10-
// exists && localInstall ? `file:~/Projects/factor/${name}` : "latest"
10+
// exists && localInstall ? `file:~/Projects/fiction/${name}` : "latest"
1111
// }
1212
// })
1313
return deps
1414
}
1515

1616
function readPackage(pkg, _context) {
17-
pkg.dependencies = rewriteFactorDependency(pkg.dependencies)
18-
pkg.devDependencies = rewriteFactorDependency(pkg.devDependencies)
17+
pkg.dependencies = rewriteFictionDependency(pkg.dependencies)
18+
pkg.devDependencies = rewriteFictionDependency(pkg.devDependencies)
1919

2020
return pkg
2121
}

.prettierignore

-5
This file was deleted.

.prettierrc

-6
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

.textlintrc.json

-11
This file was deleted.

@fiction/core/inject.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { vue } from './utils'
2-
import type { FactorApp } from './plugin-app'
3-
import type { FactorRouter } from './plugin-router'
4-
import type { FactorUser } from './plugin-user'
5-
import type { FactorEnv, ServiceList } from './plugin-env'
6-
import type { FactorMedia } from './plugin-media'
7-
import type { FactorDb } from './plugin-db'
8-
import type { FactorServer } from './plugin-server'
2+
import type { FictionApp } from './plugin-app'
3+
import type { FictionRouter } from './plugin-router'
4+
import type { FictionUser } from './plugin-user'
5+
import type { FictionEnv, ServiceList } from './plugin-env'
6+
import type { FictionMedia } from './plugin-media'
7+
import type { FictionDb } from './plugin-db'
8+
import type { FictionServer } from './plugin-server'
99

1010
export type RunVars = {
1111
APP_INSTANCE: string
@@ -32,13 +32,13 @@ export type RunVars = {
3232
}
3333

3434
export type StandardServices = {
35-
factorRouter: FactorRouter
36-
factorUser: FactorUser
37-
factorEnv: FactorEnv
38-
factorApp: FactorApp
39-
factorMedia: FactorMedia
40-
factorDb: FactorDb
41-
factorServer: FactorServer
35+
fictionRouter: FictionRouter
36+
fictionUser: FictionUser
37+
fictionEnv: FictionEnv
38+
fictionApp: FictionApp
39+
fictionMedia: FictionMedia
40+
fictionDb: FictionDb
41+
fictionServer: FictionServer
4242
runVars?: RunVars
4343
} & ServiceList
4444

@fiction/core/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"bin": {
3-
"factor": "./plugin-env/cli.js"
3+
"fiction": "./plugin-env/cli.js"
44
},
55
"buildOptions": [
66
{
@@ -137,7 +137,7 @@
137137
},
138138
"devDependencies": {
139139
"@babel/parser": "^7.24.0",
140-
"@playwright/test": "^1.42.0",
140+
"@playwright/test": "^1.42.1",
141141
"@tailwindcss/forms": "^0.5.7",
142142
"@types/bcrypt": "^5.0.2",
143143
"@types/body-parser": "^1.19.5",
@@ -169,7 +169,7 @@
169169
"deep-object-diff": "^1.1.9",
170170
"fake-indexeddb": "^5.0.2",
171171
"ngrok": "5.0.0-beta.2",
172-
"playwright": "^1.42.0",
172+
"playwright": "^1.42.1",
173173
"react-dom": "^18.2.0",
174174
"rollup": "^4.12.0",
175175
"util": "^0.12.5",

@fiction/core/plugin-app/index.ts

+54-54
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ import type { Express } from 'express'
66
import { createHead } from '@unhead/vue'
77
import type { HookType } from '../utils'
88
import { initializeResetUi, safeDirname, vue } from '../utils'
9-
import type { FactorAppEntry, FactorEnv, ServiceConfig, ServiceList } from '../plugin-env'
10-
import { FactorPlugin } from '../plugin'
11-
import type { FactorBuild } from '../plugin-build'
12-
import type { FactorRouter } from '../plugin-router'
9+
import type { FictionAppEntry, FictionEnv, ServiceConfig, ServiceList } from '../plugin-env'
10+
import { FictionPlugin } from '../plugin'
11+
import type { FictionBuild } from '../plugin-build'
12+
import type { FictionRouter } from '../plugin-router'
1313
import type { RunVars, StandardServices } from '../inject'
14-
import { FactorRender } from './plugin-render'
14+
import { FictionRender } from './plugin-render'
1515
import ElRoot from './ElRoot.vue'
16-
import type { FactorSitemap } from './sitemap'
16+
import type { FictionSitemap } from './sitemap'
1717
import type { SiteMapEntry } from './types'
1818

1919
type HookDictionary = {
20-
beforeAppMounted: { args: [FactorAppEntry] }
21-
appMounted: { args: [FactorAppEntry] }
20+
beforeAppMounted: { args: [FictionAppEntry] }
21+
appMounted: { args: [FictionAppEntry] }
2222
afterAppSetup: { args: [{ service: ServiceList }] }
2323
viteConfig: { args: [vite.InlineConfig[]] }
2424
headTags: { args: [string, { pathname?: string }] }
2525
htmlBody: { args: [string, { pathname?: string }] }
2626
}
2727

28-
export interface FactorAppSettings {
28+
export interface FictionAppSettings {
2929
hooks?: HookType<HookDictionary>[]
3030
mode?: 'production' | 'development'
3131
isTest?: boolean
@@ -34,9 +34,9 @@ export interface FactorAppSettings {
3434
isLive?: vue.Ref<boolean>
3535
altHostnames?: { dev: string, prod: string }[]
3636
port: number
37-
factorEnv: FactorEnv
37+
fictionEnv: FictionEnv
3838
rootComponent?: vue.Component
39-
factorRouter: FactorRouter
39+
fictionRouter: FictionRouter
4040
sitemaps?: SiteMapEntry[]
4141
uiPaths?: string[]
4242
tailwindConfig?: Partial<TailwindConfig>[]
@@ -47,18 +47,18 @@ export interface FactorAppSettings {
4747
[key: string]: unknown
4848
}
4949

50-
export class FactorApp extends FactorPlugin<FactorAppSettings> {
51-
isLive = this.settings.isLive ?? this.settings.factorEnv.isProd
50+
export class FictionApp extends FictionPlugin<FictionAppSettings> {
51+
isLive = this.settings.isLive ?? this.settings.fictionEnv.isProd
5252
viteDevServer?: vite.ViteDevServer
5353
hooks = this.settings.hooks ?? []
5454
uiPaths = this.settings.uiPaths ?? []
55-
factorRouter = this.settings.factorRouter
55+
fictionRouter = this.settings.fictionRouter
5656
isTest = this.settings.isTest || this.utils.isTest()
5757
rootComponent = this.settings.rootComponent || ElRoot
58-
factorEnv = this.settings.factorEnv
59-
factorBuild?: FactorBuild
60-
factorSitemap?: FactorSitemap
61-
factorRender?: FactorRender
58+
fictionEnv = this.settings.fictionEnv
59+
fictionBuild?: FictionBuild
60+
fictionSitemap?: FictionSitemap
61+
fictionRender?: FictionRender
6262
appName: string
6363
appEmail: string
6464
sitemaps = this.settings.sitemaps ?? []
@@ -73,49 +73,49 @@ export class FactorApp extends FactorPlugin<FactorAppSettings> {
7373
return isLive ? this.liveUrl.value : this.localUrl
7474
})
7575

76-
srcFolder = this.settings.srcFolder || this.factorEnv.cwd
76+
srcFolder = this.settings.srcFolder || this.fictionEnv.cwd
7777
mainIndexHtml = this.settings.mainIndexHtml || path.join(this.srcFolder, 'index.html')
7878
publicFolder = this.settings.publicFolder || path.join(this.srcFolder, 'public')
7979

8080
appInstanceId = this.settings.appInstanceId || 'app'
8181
root = safeDirname(import.meta.url)
8282

83-
constructor(settings: FactorAppSettings) {
83+
constructor(settings: FictionAppSettings) {
8484
super('app', settings)
8585

86-
this.appEmail = this.factorEnv.appEmail
87-
this.appName = this.factorEnv.appName
86+
this.appEmail = this.fictionEnv.appEmail
87+
this.appName = this.fictionEnv.appName
8888
/**
8989
* node application init
9090
*/
91-
if (!this.factorEnv.isApp.value && this.factorEnv?.cwd) {
92-
this.factorRender = new FactorRender({
93-
factorApp: this,
94-
factorEnv: this.factorEnv,
95-
factorRouter: this.factorRouter,
91+
if (!this.fictionEnv.isApp.value && this.fictionEnv?.cwd) {
92+
this.fictionRender = new FictionRender({
93+
fictionApp: this,
94+
fictionEnv: this.fictionEnv,
95+
fictionRouter: this.fictionRouter,
9696
})
9797
}
9898

9999
this.addSchema()
100100
}
101101

102102
addSchema() {
103-
if (this.factorEnv) {
104-
this.factorEnv.addHook({
103+
if (this.fictionEnv) {
104+
this.fictionEnv.addHook({
105105
hook: 'staticSchema',
106106
callback: async (existing) => {
107-
const routeKeys = this.factorRouter.routes.value?.map(_ => _.name).filter(Boolean).sort()
107+
const routeKeys = this.fictionRouter.routes.value?.map(_ => _.name).filter(Boolean).sort()
108108

109109
return { ...existing, routes: { enum: routeKeys, type: 'string' }, menus: { enum: [''], type: 'string' } }
110110
},
111111
})
112112

113-
this.factorEnv.addHook({
113+
this.fictionEnv.addHook({
114114
hook: 'staticConfig',
115115
callback: (
116116
schema: Record<string, unknown>,
117117
): Record<string, unknown> => {
118-
return { ...schema, routes: this.factorRouter.routes.value?.map(ep => ({ key: ep.name, path: ep.path })) }
118+
return { ...schema, routes: this.fictionRouter.routes.value?.map(ep => ({ key: ep.name, path: ep.path })) }
119119
},
120120
})
121121
}
@@ -139,28 +139,28 @@ export class FactorApp extends FactorPlugin<FactorAppSettings> {
139139
}
140140

141141
async buildApp(options: { render?: boolean, serve?: boolean } = {}) {
142-
if (this.factorEnv.isApp.value)
142+
if (this.fictionEnv.isApp.value)
143143
return
144-
return this.factorRender?.buildApp(options)
144+
return this.fictionRender?.buildApp(options)
145145
}
146146

147147
async serveStaticApp() {
148-
if (this.factorEnv.isApp.value)
148+
if (this.fictionEnv.isApp.value)
149149
return
150-
return this.factorRender?.serveStaticApp()
150+
return this.fictionRender?.serveStaticApp()
151151
}
152152

153153
createVueApp = async (args: {
154154
renderRoute?: string
155155
runVars?: Partial<RunVars>
156156
service: ServiceList & Partial<StandardServices>
157-
}): Promise<FactorAppEntry> => {
157+
}): Promise<FictionAppEntry> => {
158158
const { renderRoute, service, runVars } = args
159159

160-
const router = this.factorRouter.create({ caller: `mountApp:${this.appInstanceId}` })
160+
const router = this.fictionRouter.create({ caller: `mountApp:${this.appInstanceId}` })
161161

162162
if (renderRoute)
163-
await this.factorRouter.replace({ path: renderRoute }, { id: 'mount' })
163+
await this.fictionRouter.replace({ path: renderRoute }, { id: 'mount' })
164164

165165
await this.utils.runHooks<HookDictionary, 'afterAppSetup'>({
166166
list: this.hooks,
@@ -172,8 +172,8 @@ export class FactorApp extends FactorPlugin<FactorAppSettings> {
172172
? vue.createSSRApp(this.rootComponent)
173173
: vue.createApp(this.rootComponent)
174174

175-
this.factorEnv.service.value = { ...this.factorEnv.service.value, ...service, runVars }
176-
app.provide('service', this.factorEnv.service)
175+
this.fictionEnv.service.value = { ...this.fictionEnv.service.value, ...service, runVars }
176+
app.provide('service', this.fictionEnv.service)
177177

178178
app.use(router)
179179

@@ -193,14 +193,14 @@ export class FactorApp extends FactorPlugin<FactorAppSettings> {
193193
runVars?: Partial<RunVars>
194194
service: ServiceList & Partial<StandardServices>
195195
serviceConfig?: ServiceConfig
196-
}): Promise<FactorAppEntry> {
196+
}): Promise<FictionAppEntry> {
197197
const { selector = '#app', renderRoute, service, runVars, serviceConfig } = args
198198

199-
await this.factorEnv.crossRunCommand({ context: 'app', serviceConfig, runVars })
199+
await this.fictionEnv.crossRunCommand({ context: 'app', serviceConfig, runVars })
200200

201201
const entry = await this.createVueApp({ renderRoute, runVars, service })
202202

203-
if (typeof window !== 'undefined' && !this.factorEnv.isSSR.value) {
203+
if (typeof window !== 'undefined' && !this.fictionEnv.isSSR.value) {
204204
await this.utils.runHooks<HookDictionary, 'beforeAppMounted'>({
205205
list: this.hooks,
206206
hook: 'beforeAppMounted',
@@ -212,7 +212,7 @@ export class FactorApp extends FactorPlugin<FactorAppSettings> {
212212
if (!mountEl)
213213
throw new Error(`mountEl not found: ${selector}`)
214214

215-
initializeResetUi(this.factorRouter).catch(console.error)
215+
initializeResetUi(this.fictionRouter).catch(console.error)
216216
entry.app.mount(mountEl)
217217

218218
document.documentElement.style.opacity = '1'
@@ -250,11 +250,11 @@ export class FactorApp extends FactorPlugin<FactorAppSettings> {
250250
async ssrServerSetup(
251251
args: { isProd?: boolean, expressApp?: Express } = {},
252252
): Promise<Express | undefined> {
253-
if (this.factorEnv.isApp.value || !this.factorRender)
253+
if (this.fictionEnv.isApp.value || !this.fictionRender)
254254
return
255255

256256
const { isProd = false, expressApp } = args
257-
const eApp = await this.factorRender.createExpressApp({ isProd, expressApp })
257+
const eApp = await this.fictionRender.createExpressApp({ isProd, expressApp })
258258

259259
return eApp
260260
}
@@ -263,11 +263,11 @@ export class FactorApp extends FactorPlugin<FactorAppSettings> {
263263
* This creates an endpoint server and ssr server on same port
264264
* Allows production apps to serve on one instance
265265
*/
266-
// async comboSsrServerCreate(args: { isProd?: boolean, factorServer: FactorServer, factorUser: FactorUser }) {
267-
// const { isProd = false, factorServer, factorUser } = args
268-
// factorServer.port.value = this.port
269-
// factorServer.useLocal.value = true
270-
// const srv = await factorServer.initServer({ factorUser })
266+
// async comboSsrServerCreate(args: { isProd?: boolean, fictionServer: FictionServer, fictionUser: FictionUser }) {
267+
// const { isProd = false, fictionServer, fictionUser } = args
268+
// fictionServer.port.value = this.port
269+
// fictionServer.useLocal.value = true
270+
// const srv = await fictionServer.initServer({ fictionUser })
271271
// await this.ssrServerSetup({ isProd, expressApp: srv?.expressApp })
272272
// await srv?.run()
273273
// this.logReady({ serveMode: 'comboSSR' })
@@ -277,7 +277,7 @@ export class FactorApp extends FactorPlugin<FactorAppSettings> {
277277
args: { isProd?: boolean, expressApp?: Express } = {},
278278
): Promise<http.Server | undefined> {
279279
const { isProd = false, expressApp } = args
280-
if (this.factorEnv.isApp.value || !this.factorRender)
280+
if (this.fictionEnv.isApp.value || !this.fictionRender)
281281
return
282282

283283
const eApp = await this.ssrServerSetup({ isProd, expressApp })
@@ -295,6 +295,6 @@ export class FactorApp extends FactorPlugin<FactorAppSettings> {
295295
this.log.info('close app')
296296
this.appServer?.close()
297297
this.staticServer?.close()
298-
await this.factorRender?.viteDevServer?.close()
298+
await this.fictionRender?.viteDevServer?.close()
299299
}
300300
}

0 commit comments

Comments
 (0)