@h-ai/cli 0.1.0-alpha.50 → 0.1.0-alpha.51
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/dist/index.js +52 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/templates/apps/api/.dockerignore.hbs +14 -0
- package/templates/apps/api/Dockerfile.hbs +34 -0
- package/templates/apps/api/apps/{{projectName}}-service/README.md.hbs +6 -0
- package/templates/apps/api/apps/{{projectName}}-service/config/_core.yml.hbs +2 -2
- package/templates/apps/api/apps/{{projectName}}-service/config/_serv.yml.hbs +4 -4
- package/templates/apps/api/apps/{{projectName}}-service/package.json.hbs +2 -0
- package/templates/apps/api/package.json.hbs +4 -0
- package/templates/apps/fullstack/.dockerignore.hbs +14 -0
- package/templates/apps/fullstack/Dockerfile.hbs +71 -0
- package/templates/apps/fullstack/docker/fullstack-server.mjs.hbs +194 -0
- package/templates/apps/fullstack/docker/nginx.conf.hbs +18 -0
- package/templates/apps/fullstack/package.json.hbs +8 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/README.md.hbs +7 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_core.yml.hbs +2 -2
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_serv.yml.hbs +3 -3
- package/templates/apps/fullstack/packages/{{projectName}}-serv/package.json.hbs +6 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/api/api-client.ts.hbs +2 -1
- package/templates/base/.dockerignore.hbs +17 -0
- package/templates/base/Dockerfile.hbs +56 -0
- package/templates/base/docker/nginx.conf.hbs +18 -0
- package/templates/base/package.json.hbs +16 -6
- package/templates/base/svelte.config.js.hbs +0 -8
- package/templates/skills/hai-app-create/SKILL.md +13 -0
package/dist/index.js
CHANGED
|
@@ -1110,7 +1110,7 @@ PORT=3000
|
|
|
1110
1110
|
resolvedOptions.name
|
|
1111
1111
|
);
|
|
1112
1112
|
const appTypeLabel = APP_TYPES[resolvedOptions.appType].name;
|
|
1113
|
-
const readmeContent = resolvedOptions.appType === "fullstack" ? generateFullstackReadme(resolvedOptions.name, resolvedOptions.packageManager, resolvedOptions.frontends) : resolvedOptions.appType === "api" ? generateApiWorkspaceReadme(resolvedOptions.name, resolvedOptions.packageManager) : generateReadme(resolvedOptions.name, appTypeLabel, resolvedOptions.packageManager);
|
|
1113
|
+
const readmeContent = resolvedOptions.appType === "fullstack" ? generateFullstackReadme(resolvedOptions.name, resolvedOptions.packageManager, resolvedOptions.frontends) : resolvedOptions.appType === "api" ? generateApiWorkspaceReadme(resolvedOptions.name, resolvedOptions.packageManager) : generateReadme(resolvedOptions.name, appTypeLabel, resolvedOptions.packageManager, resolvedOptions.appType);
|
|
1114
1114
|
await writeFile(
|
|
1115
1115
|
path2.join(projectPath, "README.md"),
|
|
1116
1116
|
readmeContent
|
|
@@ -1612,8 +1612,20 @@ function normalizeChildOutput(output) {
|
|
|
1612
1612
|
}
|
|
1613
1613
|
return "";
|
|
1614
1614
|
}
|
|
1615
|
-
function generateReadme(name, appTypeLabel, pm) {
|
|
1615
|
+
function generateReadme(name, appTypeLabel, pm, appType) {
|
|
1616
1616
|
const install = getInstallCommand(pm);
|
|
1617
|
+
const isStaticImage = appType === "mobile-app";
|
|
1618
|
+
const containerPort = isStaticImage ? 8080 : 3e3;
|
|
1619
|
+
const runtimeOptions = isStaticImage ? "" : ` --env-file .env --mount type=bind,source=/absolute/path/to/config,target=/app/config,readonly --mount type=volume,source=${name}-data,target=/app/data`;
|
|
1620
|
+
const embeddedData = isStaticImage ? "" : `
|
|
1621
|
+
\u5982\u9700\u628A\u5F53\u524D \`data/\`\uFF08\u4F8B\u5982\u9884\u7F6E SQLite \u6587\u4EF6\uFF09\u56FA\u5316\u4E3A\u955C\u50CF\u521D\u59CB\u5FEB\u7167\uFF1A
|
|
1622
|
+
|
|
1623
|
+
\`\`\`bash
|
|
1624
|
+
${getRunCommand(pm, "docker:build:data")}
|
|
1625
|
+
\`\`\`
|
|
1626
|
+
|
|
1627
|
+
\u8FD0\u884C\u540E\u4EA7\u751F\u7684\u65B0\u6570\u636E\u4ECD\u5E94\u5199\u5165 \`/app/data\` volume\uFF1B\u914D\u7F6E\u6587\u4EF6\u53EF\u6302\u8F7D\u5230 \`/app/config\`\uFF0CYAML \u4E2D\u7684 \`\${ENV_NAME:default}\` \u53EF\u7531 \`--env-file\` \u6216 \`-e\` \u8986\u76D6\u3002
|
|
1628
|
+
`;
|
|
1617
1629
|
return `# ${name}
|
|
1618
1630
|
|
|
1619
1631
|
\u57FA\u4E8E hai Agent Framework \u6784\u5EFA\u7684${appTypeLabel}\u5E94\u7528\u3002
|
|
@@ -1633,6 +1645,14 @@ ${getRunCommand(pm, "i18n:compile")}
|
|
|
1633
1645
|
${getRunCommand(pm, "preview")}
|
|
1634
1646
|
\`\`\`
|
|
1635
1647
|
|
|
1648
|
+
## Docker
|
|
1649
|
+
|
|
1650
|
+
\`\`\`bash
|
|
1651
|
+
${getRunCommand(pm, "docker:build")}
|
|
1652
|
+
docker run --rm -p ${containerPort}:${containerPort}${runtimeOptions} ${name}:latest
|
|
1653
|
+
\`\`\`
|
|
1654
|
+
${embeddedData}
|
|
1655
|
+
|
|
1636
1656
|
## \u6587\u6863
|
|
1637
1657
|
|
|
1638
1658
|
- [hai Agent Framework](https://github.com/hai-series/hai-framework)
|
|
@@ -1666,6 +1686,19 @@ ${pm} test
|
|
|
1666
1686
|
${pm} test:e2e
|
|
1667
1687
|
\`\`\`
|
|
1668
1688
|
|
|
1689
|
+
## Docker
|
|
1690
|
+
|
|
1691
|
+
\`\`\`bash
|
|
1692
|
+
${pm} docker:build
|
|
1693
|
+
docker run --rm -p 3000:3000 --env-file .env \\
|
|
1694
|
+
--mount type=bind,source=/absolute/path/to/config,target=/app/config,readonly \\
|
|
1695
|
+
--mount type=volume,source=${name}-data,target=/app/data \\
|
|
1696
|
+
${name}:latest
|
|
1697
|
+
\`\`\`
|
|
1698
|
+
|
|
1699
|
+
- \u914D\u7F6E\u9ED8\u8BA4\u6765\u81EA \`apps/${name}-service/config\`\uFF1B\u8FD0\u884C\u65F6\u53EF\u53EA\u8BFB\u6302\u8F7D\u5230 \`/app/config\` \u8986\u76D6\uFF0C\u5E76\u7528 YAML \u7684 \`\${ENV_NAME:default}\` \u5360\u4F4D\u7B26\u63A5\u6536\u73AF\u5883\u53D8\u91CF\u3002
|
|
1700
|
+
- \u5C06 SQLite/\u672C\u5730\u5B58\u50A8\u6587\u4EF6\u653E\u5728 \`apps/${name}-service/data\` \u540E\u8FD0\u884C \`${pm} docker:build:data\`\uFF0C\u53EF\u628A\u8BE5\u76EE\u5F55\u4F5C\u4E3A\u955C\u50CF\u521D\u59CB\u6570\u636E\uFF1B\u751F\u4EA7\u5199\u5165\u4ECD\u5EFA\u8BAE\u4F7F\u7528 \`/app/data\` volume\u3002
|
|
1701
|
+
|
|
1669
1702
|
## \u6269\u5C55\u5EFA\u8BAE
|
|
1670
1703
|
|
|
1671
1704
|
- \u5728 \`${name}-contract\` \u4E2D\u7EF4\u62A4\u5E94\u7528\u7EA7 contract\uFF0C\u524D\u540E\u7AEF\u5171\u7528\u540C\u4E00\u4EFD\u7C7B\u578B\u4E0E\u8DEF\u5F84\u5B9A\u4E49\u3002
|
|
@@ -1714,6 +1747,23 @@ ${pm} package
|
|
|
1714
1747
|
${pm} deploy
|
|
1715
1748
|
\`\`\`
|
|
1716
1749
|
|
|
1750
|
+
## Docker
|
|
1751
|
+
|
|
1752
|
+
\u9ED8\u8BA4\u955C\u50CF\u628A Web \u4E0E API Service \u5408\u5E76\u4E3A\u540C\u6E90\u5165\u53E3\uFF0C\u5916\u90E8\u7AEF\u53E3\u4E3A 8080\uFF1A
|
|
1753
|
+
|
|
1754
|
+
\`\`\`bash
|
|
1755
|
+
${pm} docker:build
|
|
1756
|
+
docker run --rm -p 8080:8080 --env-file .env \\
|
|
1757
|
+
--mount type=bind,source=/absolute/path/to/config,target=/app/service/config,readonly \\
|
|
1758
|
+
--mount type=volume,source=${name}-data,target=/app/service/data \\
|
|
1759
|
+
${name}:latest
|
|
1760
|
+
\`\`\`
|
|
1761
|
+
|
|
1762
|
+
- \u914D\u7F6E\u9ED8\u8BA4\u6765\u81EA \`packages/${name}-serv/config\`\uFF0C\u4E5F\u53EF\u6302\u8F7D\u5230 \`/app/service/config\`\uFF1BYAML \u4E2D\u7684 \`\${ENV_NAME:default}\` \u53EF\u7531 \`--env-file\` \u6216 \`-e\` \u6CE8\u5165\u3002
|
|
1763
|
+
- \u5C06\u9884\u7F6E SQLite/\u672C\u5730\u5B58\u50A8\u653E\u5165 \`packages/${name}-serv/data\` \u540E\u8FD0\u884C \`${pm} docker:build:data\`\uFF0C\u53EF\u751F\u6210\u5E26\u521D\u59CB\u6570\u636E\u7684\u955C\u50CF\uFF1B\u6301\u4E45\u5316\u5199\u5165\u4ECD\u5E94\u4F7F\u7528 volume\u3002
|
|
1764
|
+
- \`HAI_WEB_PORT\` \u63A7\u5236\u5408\u5E76\u955C\u50CF\u7684 Web \u7AEF\u53E3\uFF0C\`HAI_SERV_PORT\` \u63A7\u5236\u5BB9\u5668\u5185 Service \u7AEF\u53E3\u3002
|
|
1765
|
+
- \u9700\u8981\u62C6\u5206\u90E8\u7F72\u65F6\uFF0C\u4F7F\u7528 \`${pm} docker:build:service\`${frontends.includes("web") ? ` \u4E0E \`${pm} docker:build:web -- --build-arg PUBLIC_API_BASE=https://api.example.com\`` : ""}\u3002
|
|
1766
|
+
|
|
1717
1767
|
\u524D\u7AEF\u5355\u72EC\u4EA4\u4ED8\u547D\u4EE4\uFF1A
|
|
1718
1768
|
|
|
1719
1769
|
- Web\uFF1A\`${pm} --filter ${name}-web build\` / \`${pm} --filter ${name}-web package\`
|