Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Create Llama
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
run-llama
Create Llama
Commits
82ce5db4
Commit
82ce5db4
authored
1 year ago
by
Huu Le (Lee)
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: add handle error from template installation (#522)
Co-authored-by:
Marcus Schiesser
<
mail@marcusschiesser.de
>
parent
56f8942e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
create-app.ts
+49
-19
49 additions, 19 deletions
create-app.ts
helpers/python.ts
+8
-13
8 additions, 13 deletions
helpers/python.ts
helpers/typescript.ts
+3
-1
3 additions, 1 deletion
helpers/typescript.ts
with
60 additions
and
33 deletions
create-app.ts
+
49
−
19
View file @
82ce5db4
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-extraneous-dependencies */
import
path
from
"
path
"
;
import
path
from
"
path
"
;
import
{
green
,
yellow
}
from
"
picocolors
"
;
import
{
green
,
red
}
from
"
picocolors
"
;
import
{
tryGitInit
}
from
"
./helpers/git
"
;
import
{
tryGitInit
}
from
"
./helpers/git
"
;
import
{
isFolderEmpty
}
from
"
./helpers/is-folder-empty
"
;
import
{
isFolderEmpty
}
from
"
./helpers/is-folder-empty
"
;
import
{
getOnline
}
from
"
./helpers/is-online
"
;
import
{
getOnline
}
from
"
./helpers/is-online
"
;
...
@@ -87,28 +87,48 @@ export async function createApp({
...
@@ -87,28 +87,48 @@ export async function createApp({
tools
,
tools
,
};
};
let
installationErrors
=
[];
if
(
frontend
)
{
if
(
frontend
)
{
// install backend
// install backend
const
backendRoot
=
path
.
join
(
root
,
"
backend
"
);
const
backendRoot
=
path
.
join
(
root
,
"
backend
"
);
await
makeDir
(
backendRoot
);
await
makeDir
(
backendRoot
);
await
installTemplate
({
...
args
,
root
:
backendRoot
,
backend
:
true
});
try
{
await
installTemplate
({
...
args
,
root
:
backendRoot
,
backend
:
true
,
});
}
catch
(
error
)
{
installationErrors
.
push
(
error
);
console
.
log
(
red
(
`
${
error
}
`
));
}
// install frontend
// install frontend
const
frontendRoot
=
path
.
join
(
root
,
"
frontend
"
);
const
frontendRoot
=
path
.
join
(
root
,
"
frontend
"
);
await
makeDir
(
frontendRoot
);
await
makeDir
(
frontendRoot
);
await
installTemplate
({
try
{
...
args
,
await
installTemplate
({
root
:
frontendRoot
,
...
args
,
framework
:
"
nextjs
"
,
root
:
frontendRoot
,
customApiPath
:
`http://localhost:
${
externalPort
??
8000
}
/api/chat`
,
framework
:
"
nextjs
"
,
backend
:
false
,
customApiPath
:
`http://localhost:
${
externalPort
??
8000
}
/api/chat`
,
});
backend
:
false
,
});
}
catch
(
error
)
{
installationErrors
.
push
(
error
);
}
// copy readme for fullstack
// copy readme for fullstack
await
fs
.
promises
.
copyFile
(
await
fs
.
promises
.
copyFile
(
path
.
join
(
templatesDir
,
"
README-fullstack.md
"
),
path
.
join
(
templatesDir
,
"
README-fullstack.md
"
),
path
.
join
(
root
,
"
README.md
"
),
path
.
join
(
root
,
"
README.md
"
),
);
);
}
else
{
}
else
{
await
installTemplate
({
...
args
,
backend
:
true
,
forBackend
:
framework
});
try
{
await
installTemplate
({
...
args
,
backend
:
true
,
forBackend
:
framework
});
}
catch
(
error
)
{
installationErrors
.
push
(
error
);
}
}
}
process
.
chdir
(
root
);
process
.
chdir
(
root
);
...
@@ -119,7 +139,7 @@ export async function createApp({
...
@@ -119,7 +139,7 @@ export async function createApp({
if
(
toolsRequireConfig
(
tools
))
{
if
(
toolsRequireConfig
(
tools
))
{
console
.
log
(
console
.
log
(
yellow
(
red
(
`You have selected tools that require configuration. Please configure them in the
${
terminalLink
(
`You have selected tools that require configuration. Please configure them in the
${
terminalLink
(
"
tools_config.json
"
,
"
tools_config.json
"
,
`file://
${
root
}
/tools_config.json`
,
`file://
${
root
}
/tools_config.json`
,
...
@@ -127,14 +147,24 @@ export async function createApp({
...
@@ -127,14 +147,24 @@ export async function createApp({
),
),
);
);
}
}
console
.
log
(
""
);
console
.
log
(
`
${
green
(
"
Success!
"
)}
Created
${
appName
}
at
${
appPath
}
`
);
console
.
log
(
`Now have a look at the
${
terminalLink
(
"
README.md
"
,
`file://
${
root
}
/README.md`
,
)}
and learn how to get started.`
,
);
console
.
log
();
console
.
log
();
if
(
installationErrors
.
length
>
0
)
{
for
(
const
error
of
installationErrors
)
{
console
.
log
(
red
(
`
${
error
}
`
));
}
console
.
log
(
"
\n
Exiting installation. Please check the generated code or try create app again!
"
,
);
process
.
exit
(
1
);
}
else
{
console
.
log
(
`
${
green
(
"
Success!
"
)}
Created
${
appName
}
at
${
appPath
}
`
);
console
.
log
(
`Now have a look at the
${
terminalLink
(
"
README.md
"
,
`file://
${
root
}
/README.md`
,
)}
and learn how to get started.`
,
);
console
.
log
();
}
}
}
This diff is collapsed.
Click to expand it.
helpers/python.ts
+
8
−
13
View file @
82ce5db4
import
fs
from
"
fs/promises
"
;
import
fs
from
"
fs/promises
"
;
import
path
from
"
path
"
;
import
path
from
"
path
"
;
import
{
cyan
,
red
,
yellow
}
from
"
picocolors
"
;
import
{
cyan
}
from
"
picocolors
"
;
import
{
parse
,
stringify
}
from
"
smol-toml
"
;
import
{
parse
,
stringify
}
from
"
smol-toml
"
;
import
terminalLink
from
"
terminal-link
"
;
import
terminalLink
from
"
terminal-link
"
;
import
{
copy
}
from
"
./copy
"
;
import
{
copy
}
from
"
./copy
"
;
...
@@ -103,22 +103,16 @@ export const installPythonDependencies = (
...
@@ -103,22 +103,16 @@ export const installPythonDependencies = (
);
);
const
installSuccessful
=
tryPoetryInstall
(
noRoot
);
const
installSuccessful
=
tryPoetryInstall
(
noRoot
);
if
(
!
installSuccessful
)
{
if
(
!
installSuccessful
)
{
console
.
e
rror
(
throw
new
E
rror
(
red
(
"
I
nstall failed. Please install dependencies manually.
"
)
,
"
Poetry i
nstall
ation
failed. Please install dependencies manually.
"
,
);
);
process
.
exit
(
1
);
}
}
}
else
{
}
else
{
console
.
warn
(
throw
new
Error
(
`Poetry is not available in the current environment. The Python dependencies will not be installed automatically.
yellow
(
`Poetry is not available in the current environment. The Python dependencies will not be installed automatically.
Please check
${
terminalLink
(
Please check
${
terminalLink
(
"
Poetry Installation
"
,
"
Poetry Installation
"
,
`https://python-poetry.org/docs/#installation`
,
`https://python-poetry.org/docs/#installation`
,
)}
to install poetry first, then install the dependencies manually.`
,
)}
to install poetry first, then install the dependencies manually.`
);
),
);
process
.
exit
(
1
);
}
}
};
};
...
@@ -222,4 +216,5 @@ export const installPythonTemplate = async ({
...
@@ -222,4 +216,5 @@ export const installPythonTemplate = async ({
if
(
postInstallAction
!==
"
none
"
)
{
if
(
postInstallAction
!==
"
none
"
)
{
installPythonDependencies
();
installPythonDependencies
();
}
}
console
.
log
(
"
\n
FastAPI project initialized successfully!
\n
"
);
};
};
This diff is collapsed.
Click to expand it.
helpers/typescript.ts
+
3
−
1
View file @
82ce5db4
import
fs
from
"
fs/promises
"
;
import
fs
from
"
fs/promises
"
;
import
os
from
"
os
"
;
import
os
from
"
os
"
;
import
path
from
"
path
"
;
import
path
from
"
path
"
;
import
{
bold
,
cyan
}
from
"
picocolors
"
;
import
{
bold
,
cyan
,
green
}
from
"
picocolors
"
;
import
{
version
}
from
"
../../core/package.json
"
;
import
{
version
}
from
"
../../core/package.json
"
;
import
{
copy
}
from
"
../helpers/copy
"
;
import
{
copy
}
from
"
../helpers/copy
"
;
import
{
callPackageManager
}
from
"
../helpers/install
"
;
import
{
callPackageManager
}
from
"
../helpers/install
"
;
...
@@ -231,4 +231,6 @@ export const installTSTemplate = async ({
...
@@ -231,4 +231,6 @@ export const installTSTemplate = async ({
if
(
postInstallAction
!==
"
none
"
)
{
if
(
postInstallAction
!==
"
none
"
)
{
await
installTSDependencies
(
packageJson
,
packageManager
,
isOnline
);
await
installTSDependencies
(
packageJson
,
packageManager
,
isOnline
);
}
}
console
.
log
(
green
(
`
${
framework
}
project is initialized successfully.`
));
};
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment