@logto/cli 1.5.0 → 1.6.0

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.
@@ -8,7 +8,11 @@ import { getDatabaseName } from '../../../queries/database.js';
8
8
  export const createTenant = async (pool, tenantId) => {
9
9
  const database = await getDatabaseName(pool, true);
10
10
  const { parentRole, role, password } = createTenantMetadata(database, tenantId);
11
- const createTenant = { id: tenantId, dbUser: role, dbUserPassword: password };
11
+ const createTenant = {
12
+ id: tenantId,
13
+ dbUser: role,
14
+ dbUserPassword: password,
15
+ };
12
16
  await pool.query(insertInto(createTenant, 'tenants'));
13
17
  await pool.query(sql `
14
18
  create role ${sql.identifier([role])} with inherit login
@@ -112,7 +112,7 @@ export const decompress = async (toPath, tarPath) => {
112
112
  export const seedDatabase = async (instancePath, cloud) => {
113
113
  try {
114
114
  const pool = await createPoolAndDatabaseIfNeeded();
115
- await seedByPool(pool);
115
+ await seedByPool(pool, cloud);
116
116
  await pool.end();
117
117
  }
118
118
  catch (error) {
@@ -4,7 +4,7 @@ import { got, HTTPError } from 'got';
4
4
  import { HttpsProxyAgent } from 'hpagent';
5
5
  import { z } from 'zod';
6
6
  import { consoleLog, getProxy } from '../../utils.js';
7
- import { getTranslationPrompt } from './prompts.js';
7
+ import { getTranslationPromptMessages } from './prompts.js';
8
8
  export const createOpenaiApi = () => {
9
9
  const proxy = getProxy();
10
10
  return got.extend({
@@ -30,16 +30,11 @@ export const translate = async ({ api, targetLanguage, sourceFilePath, extraProm
30
30
  .post('chat/completions', {
31
31
  json: {
32
32
  model: 'gpt-3.5-turbo',
33
- messages: [
34
- {
35
- role: 'user',
36
- content: getTranslationPrompt({
37
- sourceFileContent,
38
- targetLanguage,
39
- extraPrompt,
40
- }),
41
- },
42
- ],
33
+ messages: getTranslationPromptMessages({
34
+ sourceFileContent,
35
+ targetLanguage,
36
+ extraPrompt,
37
+ }),
43
38
  },
44
39
  })
45
40
  .json(), (error) => {
@@ -10,5 +10,8 @@ type GetTranslationPromptProperties = {
10
10
  * Remember to check the token limit before adding more prompt.
11
11
  * Tokens can be counted in https://platform.openai.com/tokenizer
12
12
  */
13
- export declare const getTranslationPrompt: ({ sourceFileContent, targetLanguage, extraPrompt, }: GetTranslationPromptProperties) => string;
13
+ export declare const getTranslationPromptMessages: ({ sourceFileContent, targetLanguage, extraPrompt, }: GetTranslationPromptProperties) => {
14
+ role: string;
15
+ content: string;
16
+ }[];
14
17
  export {};
@@ -6,13 +6,12 @@ import { conditionalString } from '@silverhand/essentials';
6
6
  * Remember to check the token limit before adding more prompt.
7
7
  * Tokens can be counted in https://platform.openai.com/tokenizer
8
8
  */
9
- export const getTranslationPrompt = ({ sourceFileContent, targetLanguage, extraPrompt, }) => `Given the following code snippet:
10
- \`\`\`ts
11
- ${sourceFileContent}
12
- \`\`\`
13
- only translate object values to ${languages[targetLanguage]}, keep all object keys original, output ts code only, the code format should be strictly consistent, and should not contains the given code snippet.
9
+ export const getTranslationPromptMessages = ({ sourceFileContent, targetLanguage, extraPrompt, }) => [
10
+ {
11
+ role: 'assistant',
12
+ content: `You are a translate assistant of a Typescript engineer, when you receive a code snippet that contains an object, translate and ONLY translate those values that are marked with comment "// UNTRANSLATED" into the language ${languages[targetLanguage]}, remove the "// UNTRANSLATED" mark, keep all object keys original, output ts code only, the code format should be strictly consistent, and should not contain the given code snippet. ${conditionalString(extraPrompt)}
14
13
 
15
- Take zh-cn as an example, if the input is:
14
+ Take Chinese as an example, if the input is:
16
15
  \`\`\`ts
17
16
  import others from './others.js';
18
17
 
@@ -35,5 +34,12 @@ const translation = {
35
34
  };
36
35
 
37
36
  export default translation;
38
- \`\`\`
39
- ${conditionalString(extraPrompt)}`;
37
+ \`\`\``,
38
+ },
39
+ {
40
+ role: 'user',
41
+ content: `\`\`\`ts
42
+ ${sourceFileContent}
43
+ \`\`\``,
44
+ },
45
+ ];
@@ -1,6 +1,6 @@
1
1
  export const packageJson = {
2
2
  "name": "@logto/cli",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Logto CLI.",
5
5
  "author": "Silverhand Inc. <contact@silverhand.io>",
6
6
  "homepage": "https://github.com/logto-io/logto#readme",
@@ -44,17 +44,17 @@ export const packageJson = {
44
44
  },
45
45
  "dependencies": {
46
46
  "@logto/connector-kit": "workspace:^1.1.1",
47
- "@logto/core-kit": "workspace:^2.0.0",
47
+ "@logto/core-kit": "workspace:^2.0.1",
48
48
  "@logto/language-kit": "workspace:^1.0.0",
49
- "@logto/phrases": "workspace:^1.4.0",
49
+ "@logto/phrases": "workspace:^1.4.1",
50
50
  "@logto/phrases-ui": "workspace:^1.2.0",
51
- "@logto/schemas": "workspace:1.5.0",
51
+ "@logto/schemas": "workspace:1.6.0",
52
52
  "@logto/shared": "workspace:^2.0.0",
53
53
  "@silverhand/essentials": "^2.5.0",
54
54
  "chalk": "^5.0.0",
55
55
  "decamelize": "^6.0.0",
56
56
  "dotenv": "^16.0.0",
57
- "got": "^12.5.3",
57
+ "got": "^13.0.0",
58
58
  "hpagent": "^1.2.0",
59
59
  "inquirer": "^9.0.0",
60
60
  "nanoid": "^4.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logto/cli",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Logto CLI.",
5
5
  "author": "Silverhand Inc. <contact@silverhand.io>",
6
6
  "homepage": "https://github.com/logto-io/logto#readme",
@@ -29,17 +29,17 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@logto/connector-kit": "^1.1.1",
32
- "@logto/core-kit": "^2.0.0",
32
+ "@logto/core-kit": "^2.0.1",
33
33
  "@logto/language-kit": "^1.0.0",
34
- "@logto/phrases": "^1.4.0",
34
+ "@logto/phrases": "^1.4.1",
35
35
  "@logto/phrases-ui": "^1.2.0",
36
- "@logto/schemas": "1.5.0",
36
+ "@logto/schemas": "1.6.0",
37
37
  "@logto/shared": "^2.0.0",
38
38
  "@silverhand/essentials": "^2.5.0",
39
39
  "chalk": "^5.0.0",
40
40
  "decamelize": "^6.0.0",
41
41
  "dotenv": "^16.0.0",
42
- "got": "^12.5.3",
42
+ "got": "^13.0.0",
43
43
  "hpagent": "^1.2.0",
44
44
  "inquirer": "^9.0.0",
45
45
  "nanoid": "^4.0.0",