fix(npmextra): update to new format
This commit is contained in:
@@ -36,9 +36,25 @@ export class AiDoc {
|
||||
this.aidocInteract = new plugins.smartinteract.SmartInteract();
|
||||
this.qenvInstance = new plugins.qenv.Qenv();
|
||||
if (!(await this.qenvInstance.getEnvVarOnDemand('OPENAI_TOKEN'))) {
|
||||
// Migrate old KV store path to new path if needed
|
||||
const homeDir = plugins.smartpath.get.home();
|
||||
const oldKvPath = plugins.path.join(homeDir, '.npmextra/kv/tsdoc.json');
|
||||
const newKvDir = plugins.path.join(homeDir, '.npmextra/kv/@git.zone');
|
||||
const newKvPath = plugins.path.join(newKvDir, 'tsdoc.json');
|
||||
if (
|
||||
await plugins.fsInstance.file(oldKvPath).exists() &&
|
||||
!(await plugins.fsInstance.file(newKvPath).exists())
|
||||
) {
|
||||
console.log('Migrating tsdoc KeyValueStore to @git.zone/tsdoc...');
|
||||
await plugins.fsInstance.directory(newKvDir).recursive().create();
|
||||
await plugins.fsInstance.file(oldKvPath).copy(newKvPath);
|
||||
await plugins.fsInstance.file(oldKvPath).delete();
|
||||
console.log('Migration complete: tsdoc.json -> @git.zone/tsdoc.json');
|
||||
}
|
||||
|
||||
this.npmextraKV = new plugins.npmextra.KeyValueStore({
|
||||
typeArg: 'userHomeDir',
|
||||
identityArg: 'tsdoc',
|
||||
identityArg: '@git.zone/tsdoc',
|
||||
mandatoryKeys: ['OPENAI_TOKEN'],
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user