Skip to content

Commit

Permalink
🐛 fix(all): up env and fix cache issue in lib
Browse files Browse the repository at this point in the history
  • Loading branch information
angelespejo committed Sep 19, 2024
1 parent edb2831 commit f7a8528
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 38 deletions.
18 changes: 18 additions & 0 deletions .dev/build-bin.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { build } from '@backan/builder'

import {
cliDistPath,
getPkg,
} from './core.mjs'

const run = async () => {

const pkg = await getPkg()

await build( {
input : cliDistPath,
name : pkg.extra.id,
} )

}
run()
9 changes: 7 additions & 2 deletions rsbuild.config.js → .dev/build-lib.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { defineConfig } from '@rsbuild/core'

import {
distPathOnly,
cliSrcPath,
} from './core.mjs'

export const distPath = 'build/in'

export default defineConfig( {
source : { entry: { cli: './src/cli.js' } },
source : { entry: { cli: cliSrcPath } },
output : {
distPath : { root: distPath },
distPath : { root: distPathOnly },
target : 'node',
filename : { js: '[name].cjs' },
},
Expand Down
18 changes: 18 additions & 0 deletions .dev/core.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { createRequire } from 'module'
import {
dirname,
join as joinPath,
} from 'path'
import { fileURLToPath } from 'url'

export { joinPath }

export const workspacePath = joinPath( dirname( fileURLToPath( import.meta.url ) ), '..' )
export const pkgPath = joinPath( workspacePath, 'package.json' )
export const cliSrcPath = joinPath( workspacePath, 'src', 'cli.js' )
export const distPathOnly = joinPath( 'build', 'in' )
export const cliDistDir = joinPath( workspacePath, distPathOnly )
export const cliDistPath = joinPath( workspacePath, distPathOnly, 'cli.cjs' )

const require = createRequire( import.meta.url )
export const getPkg = async () => require( pkgPath )
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# create-personality

## 0.2.3

### Patch Changes

- update env and fix cache from selectedModel opt

## 0.2.2

### Patch Changes
Expand Down
21 changes: 0 additions & 21 deletions build.js

This file was deleted.

8 changes: 4 additions & 4 deletions docs/todo/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

## ☀️ Core

- [ ] Save user configuration in a local folder.
- [ ] List saved configurations in the prompt line if they exist.
- [ ] Provide default configurations that the user can choose from.
- [ ] Add an option/flag "config" to set the configurations.
- [ ] Save user configuration in a local folder.
- [ ] List saved configurations in the prompt line if they exist.
- [ ] Provide default configurations that the user can choose from.
- [ ] Add an option/flag "config" to set the configurations.
- [ ] Add jsdoc in build

## 💡 Ideas
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-personality",
"version": "0.2.2",
"version": "0.2.3",
"description": "Library for crafting and sustaining AI personalities",
"keywords": [
"ia",
Expand Down Expand Up @@ -43,9 +43,9 @@
"packageManager": "pnpm@9.7.0",
"scripts": {
"dev": "vite build && node dist/cli.js",
"build": "pnpm run --sequential \"/^build:.*/\"",
"build": "pnpm run --sequential \"/build:.*/\"",
"build:lib": "vite build",
"build:bins": "rsbuild build && node ./build.js",
"build:bins": "rsbuild build -c .dev/build-lib.mjs && node .dev/build-bin.mjs",
"update-version": "changeset && changeset version",
"push": "git add . && cz && git push -f origin $@",
"push:main": "pnpm push main"
Expand All @@ -60,14 +60,14 @@
],
"license": "GPL-3.0",
"devDependencies": {
"@backan/builder": "0.0.16",
"@backan/builder": "0.0.19",
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.8",
"@chialab/esbuild-plugin-babel": "^0.18.0",
"@chialab/esbuild-plugin-meta-url": "^0.18.2",
"@chialab/esbuild-plugin-babel": "0.18.0",
"@chialab/esbuild-plugin-meta-url": "0.18.2",
"@commitlint/cli": "19.5.0",
"@pigeon-posse/eslint-config": "1.0.1",
"@rsbuild/core": "^1.0.2",
"@rsbuild/core": "1.0.5",
"@typescript-eslint/eslint-plugin": "8.2.0",
"@typescript-eslint/parser": "8.2.0",
"commitizen": "4.3.0",
Expand All @@ -88,7 +88,7 @@
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-yaml": "0.5.0",
"typescript": "5.6.2",
"vite": "^5.4.4"
"vite": "5.4.6"
},
"dependencies": {
"@clack/prompts": "0.7.0",
Expand Down
6 changes: 3 additions & 3 deletions src/personality.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ done
if ( !( this.props.selectedModel && this.props.selectedModel.length > 0 ) ) throw Error( this.texts.errorNoModels )

const successRes = ( id, initValue ) => log.success( this.questions[ id ] + ':\n' + gray( initValue ) )
const choiceFN = id => async () => {
const choiceFN = ( id, cache = true ) => async () => {

const initValue = this.flags[ id ] || this.answers[ id ]
if( initValue !== undefined ) {
Expand All @@ -372,7 +372,7 @@ done
label : model,
value : model,
} ) ),
initialValue : this.cache.get( id ),
initialValue : cache ? this.cache.get( id ) : undefined,
} )

}
Expand All @@ -387,7 +387,7 @@ done
)

},
[ this.ID.selectedModel ] : choiceFN( this.ID.selectedModel ),
[ this.ID.selectedModel ] : choiceFN( this.ID.selectedModel, false ),
[ this.ID.tone ] : choiceFN( this.ID.tone ),
[ this.ID.formality ] : choiceFN( this.ID.formality ),
[ this.ID.topics ] : choiceFN( this.ID.topics ),
Expand Down

0 comments on commit f7a8528

Please sign in to comment.