|
| 1 | +const glob = require("glob"); |
| 2 | +const fs = require("fs"); |
| 3 | +const path = require("path"); |
| 4 | +const os = require("os"); |
| 5 | +const promisify = require("util.promisify"); |
| 6 | + |
| 7 | +const globAsync = promisify(glob); |
| 8 | + |
| 9 | +const IGNORE_MODULES = [ |
| 10 | + "**/*.d.ts", |
| 11 | + "index.ts", |
| 12 | + "Utility/*", |
| 13 | + "Mapping/*", |
| 14 | + "TestDriver/*", |
| 15 | + "Primitives/*", |
| 16 | + "Mapping/**", |
| 17 | + "Documents/Session/Tokens/**", |
| 18 | + "Documents/Session/DocumentQueryCustomization", |
| 19 | + "Documents/Session/DocumentSessionAttachments", |
| 20 | + "Documents/Session/DocumentSessionAttachmentsBase", |
| 21 | + "Documents/Session/DocumentSessionRevisions", |
| 22 | + "Constants.ts", |
| 23 | + "Auth/Certificate", |
| 24 | + "Documents/Commands/CreateSubscriptionCommand*", |
| 25 | + "Documents/Commands/DeleteSubscriptionCommand*", |
| 26 | + "Documents/Commands/DropSubscriptionConnectionCommand*", |
| 27 | + "Documents/Commands/FacetQueryCommand*", |
| 28 | + "Documents/Commands/GetConflictsResult*", |
| 29 | + "Documents/Commands/GetDocumentsCommand", |
| 30 | + "Documents/Commands/GetRevisionsBinEntryCommand*", |
| 31 | + "Documents/Commands/GetRevisionsCommand*", |
| 32 | + "Documents/Commands/GetSubscriptionsCommand*", |
| 33 | + "Documents/Commands/GetSubscriptionStateCommand*", |
| 34 | + "Documents/Commands/HeadAttachmentCommand*", |
| 35 | + "Documents/Commands/HeadDocumentCommand*", |
| 36 | + "Documents/Commands/MultiGet/GetRequest*", |
| 37 | + "Documents/Commands/MultiGet/GetResponse*", |
| 38 | + "Documents/Commands/MultiGet/MultiGetCommand*", |
| 39 | + "Documents/Commands/QueryCommand*", |
| 40 | + "Documents/Commands/QueryStreamCommand*", |
| 41 | + "Documents/Commands/StreamCommand*", |
| 42 | + "Documents/Identity/**", |
| 43 | + "Documents/Indexes/IndexCreation*", |
| 44 | + "Http/RavenCommandResponsePipeline*", |
| 45 | + "Types/IRavenObject*", |
| 46 | + "Auth/Certificate*", |
| 47 | + "Documents/Operations/OperationExecutor*", |
| 48 | + "Documents/Operations/ServerOperationExecutor*", |
| 49 | + "Http/HttpCache*", |
| 50 | + "Documents/Queries/QueryResultBase*", |
| 51 | + "Documents/Queries/QueryFieldUtil*", |
| 52 | + "Documents/Queries/QueryHashCalculator*", |
| 53 | + "Documents/Session/AdvancedSessionExtensionBase*", |
| 54 | + "Documents/Session/JavaScriptArray*", |
| 55 | + "Documents/Queries/GenericQueryResult*", |
| 56 | + "Documents/Queries/IndexQueryBase*", |
| 57 | + "Documents/Queries/IndexQueryWithParameters*", |
| 58 | + "ServerWide/Tcp/TcpConnectionHeaderMessage*", |
| 59 | + "ServerWide/Tcp/TcpConnectionHeaderResponse*", |
| 60 | + "ServerWide/Tcp/TcpConnectionStatus*", |
| 61 | + "ServerWide/Tcp/TcpNegotiateParameters*", |
| 62 | + "ServerWide/Tcp/TcpNegotiation*", |
| 63 | + "Documents/Queries/MoreLikeThis/IMoreLikeThisBuilderBase*", |
| 64 | + "Documents/Queries/MoreLikeThis/MoreLikeThisQueryResult*", |
| 65 | + "Documents/Queries/MoreLikeThis/IMoreLikeThisBuilderForDocumentQuery*",, |
| 66 | + "Documents/Queries/MoreLikeThis/MoreLikeThisUsingDocument*", |
| 67 | + "Documents/Queries/MoreLikeThis/MoreLikeThisUsingAnyDocument*", |
| 68 | + "Documents/Queries/MoreLikeThis/MoreLikeThisScope*", |
| 69 | + "Documents/Queries/Suggestions/SuggestionQueryBase*", |
| 70 | + "Documents/Queries/Suggestions/SuggestionWithTerm*", |
| 71 | + "Documents/Queries/Suggestions/SuggestionWithTerms*", |
| 72 | + "Documents/Subscriptions/CreateSubscriptionResult*", |
| 73 | + "Documents/Subscriptions/GetSubscriptionResult*", |
| 74 | + "Documents/Subscriptions/GetSubscriptionsResult*", |
| 75 | + "Documents/Subscriptions/NodeId*", |
| 76 | + "Documents/Subscriptions/SubscriptionConnectionClientMessage*", |
| 77 | + "Documents/Subscriptions/SubscriptionConnectionClientMessage*", |
| 78 | + "Documents/Subscriptions/SubscriptionConnectionServerMessage*", |
| 79 | + "Documents/Subscriptions/SubscriptionOpeningStrategy*", |
| 80 | + "Documents/Subscriptions/SubscriptionStateWithNodeDetails*", |
| 81 | + "Documents/Subscriptions/SubscriptionTryout*", |
| 82 | + "Documents/Commands/**", |
| 83 | +]; |
| 84 | + |
| 85 | +function main() { |
| 86 | + return globAsync("**/*.ts", { |
| 87 | + cwd: path.join(__dirname, "../src"), |
| 88 | + ignore: IGNORE_MODULES |
| 89 | + }) |
| 90 | + .then(modules => { |
| 91 | + modules = modules.map(x => x.replace(/\/index\.ts$/, "") |
| 92 | + .replace(/\.ts$/, "")); |
| 93 | + |
| 94 | + const topLevelExports = fs.readFileSync(path.join(__dirname, "../src/index.ts")); |
| 95 | + const modulesNotExported = modules.filter(m => !topLevelExports.includes(m)); |
| 96 | + |
| 97 | + if (modulesNotExported.length) { |
| 98 | + console.error(`${ modulesNotExported.length } modules not exported at the top level:`) |
| 99 | + console.error(modulesNotExported.join(os.EOL)); |
| 100 | + return false; |
| 101 | + } |
| 102 | + |
| 103 | + console.log("All required modules exported at the top level."); |
| 104 | + |
| 105 | + return true; |
| 106 | + }); |
| 107 | +} |
| 108 | + |
| 109 | +main() |
| 110 | +.then(result => process.exit(result ? 0 : 1)) |
| 111 | +.catch(err => { |
| 112 | + console.log(err); |
| 113 | + process.exit(-1); |
| 114 | +}) |
0 commit comments