Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 4b1157c

Browse files
Merge pull request #169 from Cloud-Code-AI/main
Updating 159
2 parents 6cd4462 + df1d990 commit 4b1157c

File tree

4 files changed

+274
-137
lines changed

4 files changed

+274
-137
lines changed

.github/workflows/update-template.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,34 @@ jobs:
6262
token: ${{ steps.generate_token.outputs.token }}
6363
repository: ${{ github.repository_owner }}/akiradocs-template
6464
event-type: update-template
65-
client-payload: '{"ref": "${{ github.ref }}","sha": "${{ github.sha }}","version": "${{ steps.get-version.outputs.version }}"}'
65+
client-payload: '{"ref": "${{ github.ref }}","sha": "${{ github.sha }}","version": "${{ steps.get-version.outputs.version }}"}'
66+
67+
publish-npm:
68+
needs: trigger-update
69+
if: needs.trigger-update.outputs.version_changed == 'true'
70+
runs-on: ubuntu-latest
71+
permissions:
72+
contents: read
73+
id-token: write
74+
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- name: Setup Node.js
79+
uses: actions/setup-node@v4
80+
with:
81+
node-version: '18.x'
82+
registry-url: 'https://registry.npmjs.org'
83+
84+
- name: Install Dependencies
85+
run: npm install
86+
87+
- name: Build Package
88+
working-directory: packages/create-app
89+
run: npm run build
90+
91+
- name: Publish to NPM
92+
working-directory: packages/create-app
93+
run: npm publish
94+
env:
95+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

packages/create-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-akiradocs",
3-
"version": "1.0.39",
3+
"version": "1.0.41",
44
"description": "Create Akira Docs documentation sites with one command",
55
"main": "./dist/index.js",
66
"type": "module",

packages/create-app/src/index.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ async function copyEditor(targetDir: string) {
155155
}
156156
}
157157

158+
async function isEditorInstalled(targetDir: string) {
159+
try {
160+
const editorDir = path.join(targetDir, 'editor');
161+
await readFile(path.join(editorDir, 'package.json'), 'utf-8');
162+
return true;
163+
} catch (error) {
164+
return false;
165+
}
166+
}
167+
158168
async function main() {
159169
const packageJsonPath = path.resolve(__dirname, '../package.json');
160170
const packageJson = await readJson(packageJsonPath);
@@ -236,6 +246,31 @@ async function main() {
236246
const templateDir = path.join(__dirname, '../template/default');
237247
await updateDir(templateDir, '.');
238248

249+
// Check if editor is installed
250+
if (await isEditorInstalled('.')) {
251+
spinner.text = 'Updating editor files...';
252+
const editorCopied = await copyEditor('.');
253+
254+
if (editorCopied) {
255+
await updateEditorDependencies('.');
256+
257+
// Update package.json scripts
258+
const pkgJsonPath = path.join('.', 'package.json');
259+
const pkgJson = JSON.parse(await readFile(pkgJsonPath, 'utf-8'));
260+
pkgJson.scripts = {
261+
...pkgJson.scripts,
262+
'dev:editor': 'cd editor && npm run dev',
263+
'dev:docs': 'npm run dev',
264+
'dev:all': 'concurrently "npm run dev:docs" "npm run dev:editor"',
265+
};
266+
pkgJson.devDependencies = {
267+
...pkgJson.devDependencies,
268+
'concurrently': '^8.0.0',
269+
};
270+
await writeFile(pkgJsonPath, JSON.stringify(pkgJson, null, 2));
271+
}
272+
}
273+
239274
spinner.succeed(chalk.green('Project updated successfully!'));
240275
console.log('\nNext steps:');
241276
console.log(chalk.cyan(' npm install'));

0 commit comments

Comments
 (0)