Repository: iterative/cml (js)

Issue:
pr without arguments
Users should be allowed to manually `git commit` a few times before running `cml pr create` (not `cml pr create .`)

Since #1275 isn't released yet it means there's no way whatsoever to use `cml pr`

(from #1181 and https://github.com/iterative/cml/pull/1277#issuecomment-1339920209)

Pull request description:
Allow running `cml pr create` without files
Closes #1203, requires user experience feedback from @iterative/cml 

Patch:
diff --git a/bin/cml/pr.js b/bin/cml/pr.js
index 4e9f6b3..a28ec4b 100644
--- a/bin/cml/pr.js
+++ b/bin/cml/pr.js
@@ -17,5 +17,4 @@ exports.builder = (yargs) =>
       )
     )
     .option('options', { default: options, hidden: true })
-    .check(({ globpath }) => globpath)
     .strict();
diff --git a/bin/cml/pr/create.js b/bin/cml/pr/create.js
index 7a68a28..e8eaebb 100755
--- a/bin/cml/pr/create.js
+++ b/bin/cml/pr/create.js
@@ -9,7 +9,7 @@ const {
 const DESCRIPTION = 'Create a pull request with the specified files';
 const DOCSURL = 'https://cml.dev/doc/ref/pr';
 
-exports.command = 'create <glob path...>';
+exports.command = 'create [glob path...]';
 exports.description = `${DESCRIPTION}\n${DOCSURL}`;
 
 exports.handler = async (opts) => {
diff --git a/src/cml.js b/src/cml.js
index 15bb176..be0627c 100755
--- a/src/cml.js
+++ b/src/cml.js
@@ -543,7 +543,7 @@ class CML {
     };
 
     const { files } = await git.status();
-    if (!files.length) {
+    if (!files.length && globs.length) {
       winston.warn('No files changed. Nothing to do.');
       return;
     }
@@ -551,10 +551,6 @@ class CML {
     const paths = (await globby(globs)).filter((path) =>
       files.map((file) => file.path).includes(path)
     );
-    if (!paths.length) {
-      winston.warn('Input files are not affected. Nothing to do.');
-      return;
-    }
 
     const sha = await this.triggerSha();
     const shaShort = sha.substr(0, 8);
@@ -581,12 +577,16 @@ class CML {
       await exec(`git fetch ${remote} ${sha}`);
       await exec(`git checkout -B ${target} ${sha}`);
       await exec(`git checkout -b ${source}`);
-      await exec(`git add ${paths.join(' ')}`);
-      let commitMessage = message || `CML PR for ${shaShort}`;
-      if (skipCi || (!message && !(merge || rebase || squash))) {
-        commitMessage += ' [skip ci]';
+
+      if (paths.length) {
+        await exec(`git add ${paths.join(' ')}`);
+        let commitMessage = message || `CML PR for ${shaShort}`;
+        if (skipCi || (!message && !(merge || rebase || squash))) {
+          commitMessage += ' [skip ci]';
+        }
+        await exec(`git commit -m "${commitMessage}"`);
       }
-      await exec(`git commit -m "${commitMessage}"`);
+
       await exec(`git push --set-upstream ${remote} ${source}`);
     }
 


Test patch:
diff --git a/bin/cml/pr/create.e2e.test.js b/bin/cml/pr/create.e2e.test.js
index f2d6697..fc49cbc 100644
--- a/bin/cml/pr/create.e2e.test.js
+++ b/bin/cml/pr/create.e2e.test.js
@@ -10,7 +10,7 @@ describe('CML e2e', () => {
       Manage pull requests
 
       Commands:
-        cml.js pr create <glob path...>  Create a pull request with the specified
+        cml.js pr create [glob path...]  Create a pull request with the specified
                                          files
                                          https://cml.dev/doc/ref/pr