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

Possible to specify directory for push / pull ? #22

Closed
jondcallahan opened this issue Jan 22, 2018 · 5 comments · Fixed by #25
Closed

Possible to specify directory for push / pull ? #22

jondcallahan opened this issue Jan 22, 2018 · 5 comments · Fixed by #25

Comments

@jondcallahan
Copy link
Contributor

Expected Behavior

I have my source files in an src directory, but do some transpiling which outputs the files to a build directory. Is it possible to specify a directory to push files from?

Actual Behavior

Files are pushed and pulled from the root of the repo

Specifications

  • Node version (node -v): any
  • Version (npm list | grep clasp): 1.0.7
  • OS (Mac/Linux/Windows): Mac
@grant
Copy link
Contributor

grant commented Jan 23, 2018

Your .clasp.json file should be in the build/ directory if you want that directory to be the root. I think this is an interesting feature but probably not one that I really see being useful.

Perhaps the README can describe how this works a bit more (for users that have different folders).

@jondcallahan
Copy link
Contributor Author

jondcallahan commented Jan 23, 2018

Moving the .clasp.json file to the build directory makes it necessary to run the command from that directory. Would you be open to an optional arg passed to the push command specifying a directory? Something like:

program
  .command('push [dir]')
  .description('Update the remote project')
  .action((dir = './') => { // use './' as a default
...
   recursive(dir, (err, filePaths) => {
...
   let nameWithoutExt = name.slice(0, -path.extname(name).length);
   let formattedName = nameWithoutExt;
    if (dir !== './') {
      // Transforms build/appsscript to appsscript
      formattedName = formattedName.slice(dir.length + 1, formattedName.length);
    }
...
    return {
      name: formattedName, // the API separates the extension

@jondcallahan
Copy link
Contributor Author

Another workaround for this use case is to ignore everything but the build directory in the .claspignore. This requires the manifest file be in the project root though which doesn't work if you have environment specific manifest files that get placed in the build dir.

@grant
Copy link
Contributor

grant commented Jan 23, 2018

This is an interesting case. I'd be hesitant to add an option for push, in case one day you clasp push instead of clasp push build. Also, clasp pull would pull to the wrong dir.

It seems like the root directory should be a property of .clasp.json that defaults to . (same dir as the .clasp.json file). You normally won't push different directories all the time, so it should be a config, not a push option. Pulling should also respect the rootDir.

So .clasp.json could have:

{
  "scriptId": "1w0YR2N3Y9x_T3hbD_FGIrK5qEPATzFznF8IoNVk3enkVpkfzuU9AG4vE",
  "rootDir": "build"
}

If you want to work on this feature, I'll accept PRs.

jondcallahan added a commit to jondcallahan/clasp that referenced this issue Jan 24, 2018
@grant grant closed this as completed in #25 Jan 26, 2018
grant pushed a commit that referenced this issue Jan 26, 2018
* #22: Adds support for rootDir in .clasp.json
* Stylistic changes + properly formatting name
* object bracket spacing
@umihico
Copy link

umihico commented Aug 5, 2023

I encountered the same issue and I'd like to share my personal experience with it.

I was using @google/aside and decided to switch projects. To do this, I removed the .clasp.json file and executed clasp create [NEW_PROJECT_NAME]. After this, the rootDir property of .clasp.json was set as project root, but the original configuration for aside points to /.dist. As a result, aside attempted to upload the entire project directory, including the node_modules.

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

Successfully merging a pull request may close this issue.

3 participants