Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use generated path from git clone as target #14

Closed

Conversation

Eagle94T
Copy link

When using a private GitLab repository e.g. git+ssh://git@gitlab.com:my-org/my-project.git
the clone is performed correctly but finalFolder(target, generate) returns the wrong path, e.g.
/tmp/tmp-73792-2hsN3OqRrsZG/gitlab.commy-org
instead of
/tmp/tmp-73792-2hsN3OqRrsZG/gitlab.commy-org/my-project

This causes that the npm i --only=prod is not executed, since no package.json is found.
Therefore the whole makes for such projects does not work.

Occurs since Version 2.1.4, worked in version 2.1.3

When using a private GitLab repository e.g. `git+ssh://git@gitlab.com:my-org/my-project.git`
the clone is performed correctly but `finalFolder(target, generate)` returns the wrong path, e.g.
 `/tmp/tmp-73792-2hsN3OqRrsZG/gitlab.commy-org`
 instead of
` /tmp/tmp-73792-2hsN3OqRrsZG/gitlab.commy-org/my-project`

This causes that the `npm i --only=prod` is not executed, since no `package.json` is found.
Therefore the whole makes for such projects does not work.

Occurs since Version 2.1.4, worked in version 2.1.3
@3cp
Copy link
Member

3cp commented Apr 23, 2021

Thx.
But this doesn't break github private repo. I am investigating what went wrong with gitlab private repo.

@3cp
Copy link
Member

3cp commented Apr 24, 2021

I tried both following, works fine.

npx makes gitlab:huochunpeng/demo3
npx makes git+ssh://git@gitlab.com:huochunpeng/demo3.git

May I ask what's your git version? (Try git --version) Mine is 2.24.3.

Also, can you share the terminal log for your failed npx makes git+ssh://git@gitlab.com:my-org/my-project.git?
Something like this:

huocp@chunpengs-mbp ~/playground> npx makes git+ssh://git@gitlab.com:huochunpeng/demo3.git
makes v2.1.4 https://makes.js.org
[makes] Using remote skeleton gitlab:huochunpeng/demo3
[makes] Fetching tarball https://gitlab.com/huochunpeng/demo3/repository/archive.tar.gz?ref=master
[makes] Unable to download https://gitlab.com/huochunpeng/demo3/repository/archive.tar.gz?ref=master
302 Found
[makes] Maybe this is a private skeleton.
[makes] Preparing skeleton: git clone git@gitlab.com:huochunpeng/demo3.git gitlab.com-huochunpeng-demo3
Cloning into 'gitlab.com-huochunpeng-demo3'...
remote: Enumerating objects: 4, done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 4
Receiving objects: 100% (4/4), done.
[makes] Skeleton is ready at /var/folders/v_/y1wwsg8d7fvcr981nq9l89x00000gn/T/tmp-4284-bcoextMQUfGd/gitlab.com-huochunpeng-demo3

✔ Please name this new project: › m2y-app
[makes] Project m2y-app has been created.

Also, if you could share a screenshot (like following) of your private project page in GitLab, I can help to check the top folder structures.
Screen Shot 2021-04-24 at 7 49 39 pm

@3cp
Copy link
Member

3cp commented Apr 24, 2021

I am curious why git created extra folder my-project for your local clone. Maybe you do have a top level folder my-project inside your my-project repo...

@Eagle94T
Copy link
Author

I'm using git version 2.27.0

The log for npx makes git+ssh://git@gitlab.com:my-org/subgroup/my-project.git#my-feature-branch looks like this:

npx makes git+ssh://git@gitlab.com:my-org/subgroup/my-project.git#my-feature-branch           
npx: installed 1 in 1.629s
makes v2.1.4 https://makes.js.org
[makes] Using remote skeleton gitlab:my-org/subgroup/my-project#my-feature-branch
[makes] Fetching tarball https://gitlab.com/my-org/subgroup/my-project/repository/archive.tar.gz?ref=my-feature-branch
[makes] Unable to download https://gitlab.com/my-org/subgroup/my-project/repository/archive.tar.gz?ref=my-feature-branch
302 Found
[makes] Maybe this is a private skeleton.
[makes] Preparing skeleton: git clone git@gitlab.com:my-org/subgroup/my-project.git gitlab.com-my-org/subgroup-my-project
Cloning into 'gitlab.com-my-org/subgroup-my-project'...
remote: Enumerating objects: 56, done.
remote: Counting objects: 100% (56/56), done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 249 (delta 28), reused 49 (delta 25), pack-reused 193
Receiving objects: 100% (249/249), 473.54 KiB | 1.41 MiB/s, done.
Resolving deltas: 100% (108/108), done.
[makes] Preparing skeleton: git checkout my-feature-branch
Branch 'my-feature-branch' set up to track remote branch 'my-feature-branch' from 'origin'.
Switched to a new branch 'my-feature-branch'
[makes] Skeleton is ready at /tmp/tmp-4167-gnZsWyXrwWrw/gitlab.com-my-org/subgroup-my-project

✔ Please name this new project: › my-app
[makes] Project my-app has been created.

This log looks exactly the same way as yours, but the directory my-app does not exist at all. Do you have a project directory after running the command that contains the files of the common directory?

And the project structure looks like this:

image

The log tells that everything is fine, but the dependencies have not been installer and the follow-up questions are also missing.
A difference that I saw between my log and the one you added, is that I'm using a subgroup for my repository.

However, if I'm using version 2.1.3 of makes everything works, as you can see in this log:

npx makes@2.1.3 git+ssh://git@gitlab.com:my-org/subgroup/my-project.git#my-feature-branch     
npx: installed 1 in 0.762s
makes v2.1.3 https://makes.js.org
[makes] Using remote skeleton gitlab:my-org/subgroup/my-project#my-feature-branch
[makes] Unable to get https://gitlab.com/my-org/subgroup/my-project/repository/archive.tar.gz?ref=my-feature-branch
[makes] Maybe this is a private skeleton.
[makes] Preparing skeleton: git clone git@gitlab.com:my-org/subgroup/my-project.git gitlab.com-my-org-subgroup/my-project
Cloning into 'gitlab.com-my-org-subgroup/my-project'...
remote: Enumerating objects: 56, done.
remote: Counting objects: 100% (56/56), done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 249 (delta 28), reused 49 (delta 25), pack-reused 193
Receiving objects: 100% (249/249), 473.54 KiB | 1.11 MiB/s, done.
Resolving deltas: 100% (108/108), done.
[makes] Preparing skeleton: git checkout my-feature-branch
Branch 'my-feature-branch' set up to track remote branch 'my-feature-branch' from 'origin'.
Switched to a new branch 'my-feature-branch'
[makes] Skeleton is ready at /tmp/tmp-5787-rIhe3Ku5X6CV/gitlab.com-my-org-subgroup/my-project

[makes] Skeleton requires additional dependencies. Running npm i --only=prod
added 1 package and audited 787 packages in 2.892s
found 0 vulnerabilities

✔ Name the directory › my-app
✔ Prefix for k8s url › some-prefix
✔ Project name for the package.json package › my-app
✔ Description for this project (optional) › 
✔ Initial version for this project › 1.0.0
[makes] Project my-app has been created.

The key difference is how the subgroup is resolved into a folder.

  • For v2.14.0 it resolves to the path: my-org/subgroup-my-project
  • For v2.13.0 it resolves to the path: my-org-subgroup/my-project

There is only one production dependency in my package.json, which is: "semver": "^7.3.2"

And it's usage in in the last question:

const semverValid = require('semver/functions/valid')
module.exports = [
 ...
 {
   name: 'version',
   message: 'Initial version for this project',
   default: '1.0.0',
   validate: value => !!value && semverValid(value) ? null : 'Please only use the format "1.2.3" or "1.2.3-alpha-1"'
 }
]

@3cp
Copy link
Member

3cp commented Apr 24, 2021

Ok, I see what went wrong, your project name subgroup/my-project contains a "/" which resulting extra folder in gitlab.com-my-org-subgroup/my-project. I will test on github/gitlab/bitbucket and get back to you.

Not sure it's org name: my-org/subgroup project name: my-project, or org name: my-org project name: subgroup/my-project in gitlab, but at least hosts-git-info (which makes uses) thinks it's the second version.

@3cp
Copy link
Member

3cp commented Apr 24, 2021

All github/gitlab/bitbucket don't allow "/" in project name or org name. So far, I only saw gitlab has this group (aka org in github, workspace in bitbucket) and subgroup thing. I will adjust git clone command to avoid extra folder.

@3cp 3cp closed this in 7d69fe3 Apr 24, 2021
@3cp
Copy link
Member

3cp commented Apr 24, 2021

Try latest makes v2.1.5, it should fix your issue.

@3cp
Copy link
Member

3cp commented Apr 24, 2021

Oh, I can see there is a behaviour change between makes v2.1.3 and v2.1.4.

gitlab.com-my-org/subgroup-my-project in v2.1.4 and gitlab.com-my-org-subgroup/my-project in v2.1.3, could from a new version of hosts-git-info packed in v2.1.4.

The latest v2.1.5 should normalise it to one plain folder.

@Eagle94T
Copy link
Author

Eagle94T commented Apr 25, 2021

Version 2.1.5 fixes the problem. Thanks for the quick fix 👍🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants