Skip to content

Commit

Permalink
Revert "Remove ability to import /promise types and throw when requ…
Browse files Browse the repository at this point in the history
…ired."

This reverts commit 2ac1d3f.
  • Loading branch information
steveukx committed Aug 13, 2022
1 parent 1631776 commit bf97246
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 5 deletions.
6 changes: 6 additions & 0 deletions simple-git/package.json
Expand Up @@ -47,6 +47,9 @@
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./promise": {
"require": "./promise.js"
}
},
"types": "./typings/index.d.ts",
Expand All @@ -71,6 +74,9 @@
"types": "./dist/typings/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
},
"./promise": {
"require": "./promise.js"
}
}
}
Expand Down
69 changes: 69 additions & 0 deletions simple-git/promise.d.ts
@@ -0,0 +1,69 @@
import * as SimpleGitTypes from 'simple-git';

/**
* @deprecated
*
* simple-git has supported promises / async await since version 2.6.0.
* Importing from 'simple-git/promise' has been deprecated and will be
* removed by July 2022.
*
* To upgrade, change all 'simple-git/promise' imports to just 'simple-git'
*/
declare const simplegit: simplegit.SimpleGitExport;

declare namespace simplegit {
type SimpleGitExport = ((basePath?: string) => simplegit.SimpleGit) & {
CleanOptions: typeof SimpleGitTypes.CleanOptions;
};

/**
* @deprecated
*
* simple-git has supported promises / async await since version 2.6.0.
* Importing from 'simple-git/promise' has been deprecated and will be
* removed by July 2022.
*
* To upgrade, change all 'simple-git/promise' imports to just 'simple-git'
*/
type SimpleGit = SimpleGitTypes.SimpleGit;

// errors
type GitError = SimpleGitTypes.GitError;
type GitConstructError = SimpleGitTypes.GitConstructError;
type GitResponseError<T> = SimpleGitTypes.GitResponseError<T>;
type TaskConfigurationError = SimpleGitTypes.TaskConfigurationError;

// responses
type BranchSummary = SimpleGitTypes.BranchSummary;
type CleanSummary = SimpleGitTypes.CleanSummary;
type CleanMode = SimpleGitTypes.CleanMode;
type DiffResult = SimpleGitTypes.DiffResult;
type FetchResult = SimpleGitTypes.FetchResult;
type CommitResult = SimpleGitTypes.CommitResult;
type MergeResult = SimpleGitTypes.MergeResult;
type PullResult = SimpleGitTypes.PullResult;
type StatusResult = SimpleGitTypes.StatusResult;
type TagResult = SimpleGitTypes.TagResult;

// types
type outputHandler = SimpleGitTypes.outputHandler;
type LogOptions<T = SimpleGitTypes.DefaultLogFields> = SimpleGitTypes.LogOptions<T>;
type Options = SimpleGitTypes.Options;

// deprecated
/** @deprecated use MergeResult */
type MergeSummary = SimpleGitTypes.MergeSummary;
/** @deprecated use CommitResult */
type CommitSummary = SimpleGitTypes.CommitResult;
}

/**
* @deprecated
*
* simple-git has supported promises / async await since version 2.6.0.
* Importing from 'simple-git/promise' has been deprecated and will be
* removed by July 2022.
*
* To upgrade, change all 'simple-git/promise' imports to just 'simple-git'
*/
export = simplegit;
20 changes: 15 additions & 5 deletions simple-git/promise.js
@@ -1,8 +1,18 @@
throw new Error(`=============================================
// TODO: deprecation warning
console.warn(`=============================================
simple-git has supported promises / async await since version 2.6.0.
Importing from 'simple-git/promise' was deprecated in January 2022
and removed in August 2022.
Importing from 'simple-git/promise' has been deprecated and will be
removed by July 2022.
Upgrading is simple though:
change all 'simple-git/promise' imports to just 'simple-git'
To upgrade, change all 'simple-git/promise' imports to just 'simple-git'
=============================================`);

const simpleGit = require('.');

module.exports = Object.assign(
function () {
return simpleGit.gitP.apply(null, arguments);
},
simpleGit,
{ default: simpleGit.gitP }
);

0 comments on commit bf97246

Please sign in to comment.