@rvoh/dream 0.32.4 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/Dream.js +1 -1
- package/dist/cjs/src/bin/helpers/sync.js +2 -2
- package/dist/cjs/src/dream-application/helpers/DreamImporter.js +0 -5
- package/dist/cjs/src/dream-application/helpers/lookupClassByGlobalName.js +0 -2
- package/dist/cjs/src/dream-application/index.js +4 -10
- package/dist/cjs/src/helpers/DreamGlam/howyadoins/whaaaaaaaaaaok.js +2 -2
- package/dist/cjs/src/helpers/cli/SchemaBuilder.js +2 -2
- package/dist/cjs/src/helpers/cli/autoGeneratedFileDisclaimer.js +33 -0
- package/dist/cjs/src/helpers/loadRepl.js +3 -5
- package/dist/cjs/src/helpers/path/dreamPath.js +0 -2
- package/dist/cjs/src/index.js +3 -4
- package/dist/esm/src/Dream.js +1 -1
- package/dist/esm/src/bin/helpers/sync.js +1 -1
- package/dist/esm/src/dream-application/helpers/DreamImporter.js +0 -5
- package/dist/esm/src/dream-application/helpers/lookupClassByGlobalName.js +0 -2
- package/dist/esm/src/dream-application/index.js +4 -10
- package/dist/esm/src/helpers/DreamGlam/howyadoins/whaaaaaaaaaaok.js +2 -2
- package/dist/esm/src/helpers/cli/SchemaBuilder.js +1 -1
- package/dist/esm/src/helpers/cli/autoGeneratedFileDisclaimer.js +30 -0
- package/dist/esm/src/helpers/loadRepl.js +3 -5
- package/dist/esm/src/helpers/path/dreamPath.js +0 -2
- package/dist/esm/src/index.js +2 -2
- package/dist/types/src/Dream.d.ts +1 -1
- package/dist/types/src/dream-application/helpers/DreamImporter.d.ts +0 -1
- package/dist/types/src/dream-application/index.d.ts +5 -5
- package/dist/types/src/helpers/loadRepl.d.ts +1 -1
- package/dist/types/src/index.d.ts +3 -2
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +66 -21
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +6 -5
- package/docs/classes/Decorators.html +19 -19
- package/docs/classes/Dream.html +131 -131
- package/docs/classes/DreamApplication.html +4 -5
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamGlam.html +2 -2
- package/docs/classes/DreamImporter.html +2 -3
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializer.html +2 -2
- package/docs/classes/DreamTransaction.html +2 -2
- package/docs/classes/Encrypt.html +2 -2
- package/docs/classes/Env.html +2 -2
- package/docs/classes/GlobalNameNotSet.html +6 -5
- package/docs/classes/NonLoadedAssociation.html +6 -5
- package/docs/classes/Query.html +51 -51
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +6 -5
- package/docs/classes/ValidationError.html +6 -5
- package/docs/functions/Attribute.html +1 -1
- package/docs/functions/RendersMany.html +1 -1
- package/docs/functions/RendersOne.html +1 -1
- package/docs/functions/ReplicaSafe.html +1 -1
- package/docs/functions/STI.html +1 -1
- package/docs/functions/SoftDelete.html +1 -1
- package/docs/functions/camelize.html +1 -1
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.html +1 -1
- package/docs/functions/debug.html +1 -1
- package/docs/functions/dreamDbConnections.html +1 -1
- package/docs/functions/dreamPath.html +1 -1
- package/docs/functions/generateDream.html +1 -1
- package/docs/functions/globalClassNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/pascalize.html +1 -1
- package/docs/functions/pgErrorType.html +1 -1
- package/docs/functions/range-1.html +1 -1
- package/docs/functions/relativeDreamPath.html +1 -1
- package/docs/functions/round.html +1 -1
- package/docs/functions/serializerNameFromFullyQualifiedModelName.html +1 -1
- package/docs/functions/sharedPathPrefix.html +1 -1
- package/docs/functions/snakeify.html +1 -1
- package/docs/functions/sort.html +1 -1
- package/docs/functions/sortBy.html +1 -1
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/untypedDb.html +1 -0
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/index.html +7 -7
- package/docs/interfaces/AttributeStatement.html +2 -2
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamApplicationInitOptions.html +2 -2
- package/docs/interfaces/DreamApplicationOpts.html +2 -2
- package/docs/interfaces/DreamSerializerAssociationStatement.html +2 -2
- package/docs/interfaces/EncryptOptions.html +2 -2
- package/docs/interfaces/OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/OpenapiTypeFieldObject.html +1 -1
- package/docs/modules.html +10 -10
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DbConnectionType.html +1 -0
- package/docs/types/DreamAssociationMetadata.html +1 -1
- package/docs/types/DreamAttributes.html +1 -1
- package/docs/types/DreamClassColumn.html +1 -1
- package/docs/types/DreamColumn.html +1 -1
- package/docs/types/DreamColumnNames.html +1 -1
- package/docs/types/DreamLogLevel.html +1 -1
- package/docs/types/DreamLogger.html +1 -1
- package/docs/types/DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/DreamParamSafeAttributes.html +1 -1
- package/docs/types/DreamParamSafeColumnNames.html +1 -1
- package/docs/types/DreamSerializerKey.html +1 -1
- package/docs/types/DreamSerializers.html +1 -1
- package/docs/types/DreamTableSchema.html +1 -1
- package/docs/types/DreamVirtualColumns.html +1 -1
- package/docs/types/EncryptAlgorithm.html +1 -1
- package/docs/types/Hyphenized.html +1 -1
- package/docs/types/IdType.html +1 -1
- package/docs/types/OpenapiAllTypes.html +1 -1
- package/docs/types/OpenapiFormats.html +1 -1
- package/docs/types/OpenapiNumberFormats.html +1 -1
- package/docs/types/OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiSchemaArray.html +1 -1
- package/docs/types/OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/OpenapiSchemaBase.html +1 -1
- package/docs/types/OpenapiSchemaBody.html +1 -1
- package/docs/types/OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRef.html +1 -1
- package/docs/types/OpenapiSchemaExpressionRefSchemaShorthand.html +1 -1
- package/docs/types/OpenapiSchemaInteger.html +1 -1
- package/docs/types/OpenapiSchemaNull.html +1 -1
- package/docs/types/OpenapiSchemaNumber.html +1 -1
- package/docs/types/OpenapiSchemaObject.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/OpenapiSchemaPartialSegment.html +1 -1
- package/docs/types/OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAllOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionAnyOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionOneOf.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializableRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandExpressionSerializerRef.html +1 -1
- package/docs/types/OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/OpenapiSchemaString.html +1 -1
- package/docs/types/OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/OpenapiTypeField.html +1 -1
- package/docs/types/Pascalized.html +1 -1
- package/docs/types/PrimaryKeyType.html +1 -1
- package/docs/types/RoundingPrecision.html +1 -1
- package/docs/types/SerializableClassOrSerializerCallback.html +1 -1
- package/docs/types/SerializableDreamClassOrViewModelClass.html +1 -1
- package/docs/types/SerializableDreamOrViewModel.html +1 -1
- package/docs/types/SerializableTypes.html +1 -1
- package/docs/types/Snakeified.html +1 -1
- package/docs/types/Timestamp.html +1 -1
- package/docs/types/UpdateableAssociationProperties.html +1 -1
- package/docs/types/UpdateableProperties.html +1 -1
- package/docs/types/ValidationType.html +1 -1
- package/docs/types/ViewModelSerializerKey.html +1 -1
- package/docs/types/WhereStatementForDream.html +1 -1
- package/docs/types/WhereStatementForDreamClass.html +1 -1
- package/docs/variables/DateTime-1.html +1 -1
- package/docs/variables/DreamConst.html +1 -1
- package/docs/variables/TRIGRAM_OPERATORS.html +1 -1
- package/docs/variables/openapiPrimitiveTypes-1.html +1 -1
- package/docs/variables/openapiShorthandPrimitiveTypes-1.html +1 -1
- package/docs/variables/ops.html +1 -1
- package/docs/variables/primaryKeyTypes.html +1 -1
- package/package.json +4 -7
- package/boilerplate/app/models/ApplicationModel.ts +0 -14
- package/boilerplate/app/serializers/.gitkeep +0 -0
- package/boilerplate/bin/esm.js +0 -19
- package/boilerplate/cli/helpers/initializeDreamApplication.ts +0 -6
- package/boilerplate/cli/index.ts +0 -22
- package/boilerplate/conf/inflections.ts +0 -5
- package/boilerplate/conf/loadEnv.ts +0 -4
- package/boilerplate/conf/repl.ts +0 -11
- package/boilerplate/eslint.config.js +0 -21
- package/boilerplate/package.json +0 -39
- package/boilerplate/tsconfig.build.json +0 -41
- package/boilerplate/tsconfig.json +0 -12
- package/boilerplate/types/db.ts +0 -5
- package/boilerplate/types/dream.ts +0 -3
- package/dist/cjs/boilerplate/package.json +0 -39
- package/dist/cjs/src/dream-application/helpers/globalServiceKeyFromPath.js +0 -11
- package/dist/cjs/src/dream-application/helpers/importers/importServices.js +0 -43
- package/dist/cjs/src/global-cli/dream.js +0 -46
- package/dist/cjs/src/global-cli/file-builders/DreamtsBuilder.js +0 -69
- package/dist/cjs/src/global-cli/file-builders/EnvBuilder.js +0 -27
- package/dist/cjs/src/global-cli/file-builders/EslintConfBuilder.js +0 -29
- package/dist/cjs/src/global-cli/file-builders/PackagejsonBuilder.js +0 -9
- package/dist/cjs/src/global-cli/helpers/argAndValue.js +0 -15
- package/dist/cjs/src/global-cli/helpers/autogeneratedFileMessage.js +0 -71
- package/dist/cjs/src/global-cli/helpers/buildNewDreamApp.js +0 -63
- package/dist/cjs/src/global-cli/helpers/copyRecursive.js +0 -20
- package/dist/cjs/src/global-cli/helpers/filterObjectByKey.js +0 -23
- package/dist/cjs/src/global-cli/helpers/generateEncryptionKey.js +0 -26
- package/dist/cjs/src/global-cli/helpers/globalCliSnakeify.js +0 -1
- package/dist/cjs/src/global-cli/helpers/initDreamAppIntoExistingProject.js +0 -85
- package/dist/cjs/src/global-cli/helpers/log.js +0 -28
- package/dist/cjs/src/global-cli/helpers/logo.js +0 -81
- package/dist/cjs/src/global-cli/helpers/primaryKeyTypes.js +0 -13
- package/dist/cjs/src/global-cli/helpers/prompt.js +0 -33
- package/dist/cjs/src/global-cli/helpers/select.js +0 -113
- package/dist/cjs/src/global-cli/helpers/sleep.js +0 -10
- package/dist/cjs/src/global-cli/helpers/sspawn.js +0 -21
- package/dist/cjs/src/global-cli/helpers/welcomeMessage.js +0 -41
- package/dist/cjs/src/global-cli/init.js +0 -56
- package/dist/cjs/src/global-cli/new.js +0 -10
- package/dist/esm/boilerplate/package.json +0 -39
- package/dist/esm/src/dream-application/helpers/globalServiceKeyFromPath.js +0 -8
- package/dist/esm/src/dream-application/helpers/importers/importServices.js +0 -37
- package/dist/esm/src/global-cli/dream.js +0 -44
- package/dist/esm/src/global-cli/file-builders/DreamtsBuilder.js +0 -66
- package/dist/esm/src/global-cli/file-builders/EnvBuilder.js +0 -24
- package/dist/esm/src/global-cli/file-builders/EslintConfBuilder.js +0 -26
- package/dist/esm/src/global-cli/file-builders/PackagejsonBuilder.js +0 -6
- package/dist/esm/src/global-cli/helpers/argAndValue.js +0 -12
- package/dist/esm/src/global-cli/helpers/autogeneratedFileMessage.js +0 -68
- package/dist/esm/src/global-cli/helpers/buildNewDreamApp.js +0 -60
- package/dist/esm/src/global-cli/helpers/copyRecursive.js +0 -17
- package/dist/esm/src/global-cli/helpers/filterObjectByKey.js +0 -20
- package/dist/esm/src/global-cli/helpers/generateEncryptionKey.js +0 -23
- package/dist/esm/src/global-cli/helpers/globalCliSnakeify.js +0 -1
- package/dist/esm/src/global-cli/helpers/initDreamAppIntoExistingProject.js +0 -82
- package/dist/esm/src/global-cli/helpers/log.js +0 -24
- package/dist/esm/src/global-cli/helpers/logo.js +0 -77
- package/dist/esm/src/global-cli/helpers/primaryKeyTypes.js +0 -10
- package/dist/esm/src/global-cli/helpers/prompt.js +0 -30
- package/dist/esm/src/global-cli/helpers/select.js +0 -110
- package/dist/esm/src/global-cli/helpers/sleep.js +0 -7
- package/dist/esm/src/global-cli/helpers/sspawn.js +0 -17
- package/dist/esm/src/global-cli/helpers/welcomeMessage.js +0 -38
- package/dist/esm/src/global-cli/init.js +0 -53
- package/dist/esm/src/global-cli/new.js +0 -7
- package/dist/types/src/dream-application/helpers/globalServiceKeyFromPath.d.ts +0 -1
- package/dist/types/src/dream-application/helpers/importers/importServices.d.ts +0 -4
- package/dist/types/src/global-cli/dream.d.ts +0 -2
- package/dist/types/src/global-cli/file-builders/DreamtsBuilder.d.ts +0 -4
- package/dist/types/src/global-cli/file-builders/EnvBuilder.d.ts +0 -6
- package/dist/types/src/global-cli/file-builders/EslintConfBuilder.d.ts +0 -3
- package/dist/types/src/global-cli/file-builders/PackagejsonBuilder.d.ts +0 -3
- package/dist/types/src/global-cli/helpers/argAndValue.d.ts +0 -1
- package/dist/types/src/global-cli/helpers/buildNewDreamApp.d.ts +0 -2
- package/dist/types/src/global-cli/helpers/copyRecursive.d.ts +0 -1
- package/dist/types/src/global-cli/helpers/filterObjectByKey.d.ts +0 -1
- package/dist/types/src/global-cli/helpers/generateEncryptionKey.d.ts +0 -1
- package/dist/types/src/global-cli/helpers/globalCliSnakeify.d.ts +0 -1
- package/dist/types/src/global-cli/helpers/initDreamAppIntoExistingProject.d.ts +0 -2
- package/dist/types/src/global-cli/helpers/log.d.ts +0 -10
- package/dist/types/src/global-cli/helpers/logo.d.ts +0 -2
- package/dist/types/src/global-cli/helpers/primaryKeyTypes.d.ts +0 -22
- package/dist/types/src/global-cli/helpers/prompt.d.ts +0 -8
- package/dist/types/src/global-cli/helpers/select.d.ts +0 -17
- package/dist/types/src/global-cli/helpers/sleep.d.ts +0 -1
- package/dist/types/src/global-cli/helpers/sspawn.d.ts +0 -2
- package/dist/types/src/global-cli/helpers/welcomeMessage.d.ts +0 -1
- package/dist/types/src/global-cli/init.d.ts +0 -2
- package/dist/types/src/global-cli/new.d.ts +0 -2
- package/docs/classes/DreamDbConnection.html +0 -4
- package/docs/functions/db.html +0 -1
- /package/dist/types/src/{global-cli/helpers/autogeneratedFileMessage.d.ts → helpers/cli/autoGeneratedFileDisclaimer.d.ts} +0 -0
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = autogeneratedFileDisclaimer;
|
|
4
|
-
const logo_js_1 = require("./logo.js");
|
|
5
|
-
function autogeneratedFileDisclaimer(startComment = '\n/*', endComment = '\n*/') {
|
|
6
|
-
return `\
|
|
7
|
-
${startComment}
|
|
8
|
-
--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
|
|
9
|
-
#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
|
|
10
|
-
--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
|
|
11
|
-
#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
|
|
12
|
-
BEGIN AUTOGENERATED MESSAGE
|
|
13
|
-
--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
|
|
14
|
-
#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
|
|
15
|
-
--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
|
|
16
|
-
#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
${(0, logo_js_1.basicLogo)()}
|
|
20
|
-
|
|
21
|
-
This file was automatically generated by my cat, Aster.
|
|
22
|
-
He does not want you mucking about with his files,
|
|
23
|
-
and we are pretty lax on trimming his nails.
|
|
24
|
-
|
|
25
|
-
I mean, we have him pretty well fenced in but he is an
|
|
26
|
-
escape artist and he still manages to get fleas!
|
|
27
|
-
|
|
28
|
-
My point is, don't go mucking about with his files!
|
|
29
|
-
|
|
30
|
-
He actually has a hopefully well-tempered message for
|
|
31
|
-
us humans, he says:
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
Dear pathetic humans,
|
|
35
|
-
|
|
36
|
-
Here is a haiku to keep you in line
|
|
37
|
-
|
|
38
|
-
don't dare go mucking
|
|
39
|
-
with my files, I lyke them fine
|
|
40
|
-
prettierignore
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
Sorry, that's the best we are ganna get from him
|
|
44
|
-
when you ask him to add a disclaimer to all
|
|
45
|
-
autogenerated files on a SUNDAY, when the sun
|
|
46
|
-
is hitting the perfect spot in the living room
|
|
47
|
-
for a mid-morning nap! He can get saucy, and he
|
|
48
|
-
is looking over my shoulder and would like me to
|
|
49
|
-
remind all humans that
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
a.) I have sharp claws.
|
|
53
|
-
b.) All laptops are ok sleeping places for your
|
|
54
|
-
cat overlords. when we decide to sleep on
|
|
55
|
-
them, it is because they are our beds, and
|
|
56
|
-
we just loan them out to you so you can go
|
|
57
|
-
out and get us the right food.
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
|
|
61
|
-
#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
|
|
62
|
-
--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
|
|
63
|
-
#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
|
|
64
|
-
END AUTOGENERATED MESSAGE
|
|
65
|
-
--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
|
|
66
|
-
#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
|
|
67
|
-
--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#
|
|
68
|
-
#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--
|
|
69
|
-
${endComment}
|
|
70
|
-
`;
|
|
71
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = buildNewDreamApp;
|
|
4
|
-
const c = require("colorette");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const DreamtsBuilder_js_1 = require("../file-builders/DreamtsBuilder.js");
|
|
7
|
-
const EnvBuilder_js_1 = require("../file-builders/EnvBuilder.js");
|
|
8
|
-
const PackagejsonBuilder_js_1 = require("../file-builders/PackagejsonBuilder.js");
|
|
9
|
-
const copyRecursive_js_1 = require("./copyRecursive.js");
|
|
10
|
-
const log_js_1 = require("./log.js");
|
|
11
|
-
const primaryKeyTypes_js_1 = require("./primaryKeyTypes.js");
|
|
12
|
-
const select_js_1 = require("./select.js");
|
|
13
|
-
const sleep_js_1 = require("./sleep.js");
|
|
14
|
-
const sspawn_js_1 = require("./sspawn.js");
|
|
15
|
-
const welcomeMessage_js_1 = require("./welcomeMessage.js");
|
|
16
|
-
function testEnv() {
|
|
17
|
-
return process.env.NODE_ENV === 'test';
|
|
18
|
-
}
|
|
19
|
-
async function buildNewDreamApp(appName, projectPath, options) {
|
|
20
|
-
if (!options.primaryKeyType) {
|
|
21
|
-
const answer = await new select_js_1.default('what primary key type would you like to use?', primaryKeyTypes_js_1.cliPrimaryKeyTypes).run();
|
|
22
|
-
options.primaryKeyType = answer;
|
|
23
|
-
}
|
|
24
|
-
(0, copyRecursive_js_1.default)(__dirname + '/../../../boilerplate', `${projectPath}/src`);
|
|
25
|
-
if (!testEnv()) {
|
|
26
|
-
log_js_1.default.restoreCache();
|
|
27
|
-
log_js_1.default.write(c.green(`Step 1. write boilerplate to ${appName}: Done!`), { cache: true });
|
|
28
|
-
log_js_1.default.write(c.green(`Step 2. building default config files...`));
|
|
29
|
-
}
|
|
30
|
-
fs.writeFileSync(`${projectPath}/.env`, EnvBuilder_js_1.default.build({ appName, env: 'development' }));
|
|
31
|
-
fs.writeFileSync(`${projectPath}/.env.test`, EnvBuilder_js_1.default.build({ appName, env: 'test' }));
|
|
32
|
-
fs.writeFileSync(projectPath + '/package.json', await PackagejsonBuilder_js_1.default.buildAPI());
|
|
33
|
-
fs.writeFileSync(`${projectPath}/src/conf/dream.ts`, DreamtsBuilder_js_1.default.build(options));
|
|
34
|
-
if (!testEnv()) {
|
|
35
|
-
log_js_1.default.restoreCache();
|
|
36
|
-
log_js_1.default.write(c.green(`Step 2. build default config files: Done!`), { cache: true });
|
|
37
|
-
log_js_1.default.write(c.green(`Step 3. Installing dream dependencies...`));
|
|
38
|
-
// only run yarn install if not in test env to save time
|
|
39
|
-
await (0, sspawn_js_1.default)(`cd ${projectPath} && touch yarn.lock && yarn install`);
|
|
40
|
-
}
|
|
41
|
-
// sleeping here because yarn has a delayed print that we need to clean up
|
|
42
|
-
if (!testEnv())
|
|
43
|
-
await (0, sleep_js_1.default)(1000);
|
|
44
|
-
if (!testEnv()) {
|
|
45
|
-
log_js_1.default.restoreCache();
|
|
46
|
-
log_js_1.default.write(c.green(`Step 3. Install dream dependencies: Done!`), { cache: true });
|
|
47
|
-
log_js_1.default.write(c.green(`Step 4. Initializing git repository...`));
|
|
48
|
-
// only do this if not test, since using git in CI will fail
|
|
49
|
-
await (0, sspawn_js_1.default)(`cd ./${appName} && git init`);
|
|
50
|
-
}
|
|
51
|
-
if (!testEnv()) {
|
|
52
|
-
log_js_1.default.restoreCache();
|
|
53
|
-
log_js_1.default.write(c.green(`Step 4. Initialize git repository: Done!`), { cache: true });
|
|
54
|
-
log_js_1.default.write(c.green(`Step 5. Building project...`));
|
|
55
|
-
}
|
|
56
|
-
// don't sync yet, since we need to run migrations first
|
|
57
|
-
// await sspawn(`yarn --cwd=${projectPath} dream sync:existing`)
|
|
58
|
-
if (!testEnv()) {
|
|
59
|
-
log_js_1.default.restoreCache();
|
|
60
|
-
log_js_1.default.write(c.green(`Step 5. Build project: Done!`), { cache: true });
|
|
61
|
-
console.log((0, welcomeMessage_js_1.default)(appName));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = copyRecursive;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
function copyRecursive(src, dest) {
|
|
7
|
-
const exists = fs.existsSync(src);
|
|
8
|
-
const stats = exists && fs.statSync(src);
|
|
9
|
-
const isDirectory = exists && stats.isDirectory();
|
|
10
|
-
if (isDirectory) {
|
|
11
|
-
if (!['.', './.'].includes(dest) && !fs.existsSync(dest))
|
|
12
|
-
fs.mkdirSync(dest);
|
|
13
|
-
fs.readdirSync(src).forEach(function (childItemName) {
|
|
14
|
-
copyRecursive(path.join(src, childItemName), path.join(dest, childItemName));
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
fs.copyFileSync(src, dest);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = filterObjectByKey;
|
|
4
|
-
function filterObjectByKey(obj, arr) {
|
|
5
|
-
const workingObj = {};
|
|
6
|
-
const booleanObj = {};
|
|
7
|
-
arr.forEach(key => (booleanObj[key] = true));
|
|
8
|
-
arr.forEach(key => {
|
|
9
|
-
if (booleanObj[key])
|
|
10
|
-
workingObj[protectAgainstPollutingAssignment(key)] = obj[key];
|
|
11
|
-
});
|
|
12
|
-
return workingObj;
|
|
13
|
-
}
|
|
14
|
-
const reservedKeys = new Map([
|
|
15
|
-
['__proto__', true],
|
|
16
|
-
['constructor', true],
|
|
17
|
-
['prototype', true],
|
|
18
|
-
]);
|
|
19
|
-
function protectAgainstPollutingAssignment(key) {
|
|
20
|
-
if (reservedKeys.get(key))
|
|
21
|
-
throw new Error(`Passed "${key}" as the key to modify an object`);
|
|
22
|
-
return key;
|
|
23
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = generateEncryptionKey;
|
|
4
|
-
function generateEncryptionKey() {
|
|
5
|
-
return (Math.random().toString(36).substr(2, 10) +
|
|
6
|
-
'-' +
|
|
7
|
-
Math.random().toString(36).substr(2, 10) +
|
|
8
|
-
'-' +
|
|
9
|
-
Math.random().toString(36).substr(2, 10) +
|
|
10
|
-
'-' +
|
|
11
|
-
Math.random().toString(36).substr(2, 10) +
|
|
12
|
-
'-' +
|
|
13
|
-
Math.random().toString(36).substr(2, 10) +
|
|
14
|
-
'-' +
|
|
15
|
-
Math.random().toString(36).substr(2, 10) +
|
|
16
|
-
'-' +
|
|
17
|
-
Math.random().toString(36).substr(2, 10) +
|
|
18
|
-
'-' +
|
|
19
|
-
Math.random().toString(36).substr(2, 10) +
|
|
20
|
-
'-' +
|
|
21
|
-
Math.random().toString(36).substr(2, 10) +
|
|
22
|
-
'-' +
|
|
23
|
-
Math.random().toString(36).substr(2, 10) +
|
|
24
|
-
'-' +
|
|
25
|
-
Math.random().toString(36).substr(2, 10));
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = initDreamAppIntoExistingProject;
|
|
4
|
-
const c = require("colorette");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const DreamtsBuilder_js_1 = require("../file-builders/DreamtsBuilder.js");
|
|
8
|
-
const EnvBuilder_js_1 = require("../file-builders/EnvBuilder.js");
|
|
9
|
-
const PackagejsonBuilder_js_1 = require("../file-builders/PackagejsonBuilder.js");
|
|
10
|
-
const copyRecursive_js_1 = require("./copyRecursive.js");
|
|
11
|
-
const filterObjectByKey_js_1 = require("./filterObjectByKey.js");
|
|
12
|
-
const log_js_1 = require("./log.js");
|
|
13
|
-
const sleep_js_1 = require("./sleep.js");
|
|
14
|
-
const sspawn_js_1 = require("./sspawn.js");
|
|
15
|
-
const welcomeMessage_js_1 = require("./welcomeMessage.js");
|
|
16
|
-
async function initDreamAppIntoExistingProject(appName, options) {
|
|
17
|
-
createDirIfNotExists(options.projectPath);
|
|
18
|
-
createDirIfNotExists(path.join(options.projectPath, options.configPath));
|
|
19
|
-
createDirIfNotExists(path.join(options.projectPath, options.modelsPath));
|
|
20
|
-
createDirIfNotExists(path.join(options.projectPath, options.serializersPath));
|
|
21
|
-
createDirIfNotExists(path.join(options.projectPath, options.servicesPath));
|
|
22
|
-
createDirIfNotExists(path.join(options.dbPath, options.dbPath));
|
|
23
|
-
(0, copyRecursive_js_1.default)(__dirname + '/../../../boilerplate/conf', path.join(process.cwd(), options.projectPath, options.configPath));
|
|
24
|
-
(0, copyRecursive_js_1.default)(__dirname + '/../../../boilerplate/app/models', path.join(process.cwd(), options.projectPath, options.modelsPath));
|
|
25
|
-
(0, copyRecursive_js_1.default)(__dirname + '/../../../boilerplate/app/serializers', path.join(options.projectPath, options.serializersPath));
|
|
26
|
-
(0, copyRecursive_js_1.default)(__dirname + '/../../../boilerplate/types', path.join(process.cwd(), options.projectPath, options.dbPath));
|
|
27
|
-
if (!testEnv()) {
|
|
28
|
-
log_js_1.default.restoreCache();
|
|
29
|
-
log_js_1.default.write(c.green(`Step 1. write boilerplate to ${appName}: Done!`), { cache: true });
|
|
30
|
-
log_js_1.default.write(c.green(`Step 2. building default config files...`));
|
|
31
|
-
}
|
|
32
|
-
fs.writeFileSync(`${options.projectPath}/.env`, EnvBuilder_js_1.default.build({ appName, env: 'development' }));
|
|
33
|
-
fs.writeFileSync(`${options.projectPath}/.env.test`, EnvBuilder_js_1.default.build({ appName, env: 'test' }));
|
|
34
|
-
fs.writeFileSync(path.join(process.cwd(), options.projectPath, options.configPath, 'dream.ts'), DreamtsBuilder_js_1.default.build(options));
|
|
35
|
-
const packageJsonPath = path.join(process.cwd(), options.projectPath, 'package.json');
|
|
36
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
37
|
-
const packagejson = await Promise.resolve().then(() => require('../../../boilerplate/package.json'));
|
|
38
|
-
const userPackagejson = await Promise.resolve(`${packageJsonPath}`).then(s => require(s));
|
|
39
|
-
mergePackageJsonField('scripts', packagejson, userPackagejson);
|
|
40
|
-
mergePackageJsonField('dependencies', packagejson, userPackagejson);
|
|
41
|
-
mergePackageJsonField('devDependencies', packagejson, userPackagejson);
|
|
42
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(userPackagejson, null, 2));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
fs.writeFileSync(packageJsonPath, await PackagejsonBuilder_js_1.default.buildAPI());
|
|
46
|
-
}
|
|
47
|
-
if (!testEnv()) {
|
|
48
|
-
log_js_1.default.restoreCache();
|
|
49
|
-
log_js_1.default.write(c.green(`Step 2. build default config files: Done!`), { cache: true });
|
|
50
|
-
log_js_1.default.write(c.green(`Step 3. Installing dream dependencies...`));
|
|
51
|
-
// only run yarn install if not in test env to save time
|
|
52
|
-
await (0, sspawn_js_1.default)(`cd ${options.projectPath} && touch yarn.lock && yarn install`);
|
|
53
|
-
}
|
|
54
|
-
// sleeping here because yarn has a delayed print that we need to clean up
|
|
55
|
-
if (!testEnv())
|
|
56
|
-
await (0, sleep_js_1.default)(1000);
|
|
57
|
-
if (!testEnv()) {
|
|
58
|
-
log_js_1.default.restoreCache();
|
|
59
|
-
log_js_1.default.write(c.green(`Step 3. Install dream dependencies: Done!`), { cache: true });
|
|
60
|
-
log_js_1.default.write(c.green(`Step 4. Building project...`));
|
|
61
|
-
}
|
|
62
|
-
// don't sync yet, since we need to run migrations first
|
|
63
|
-
// await sspawn(`yarn --cwd=${projectPath} dream sync:existing`)
|
|
64
|
-
if (!testEnv()) {
|
|
65
|
-
log_js_1.default.restoreCache();
|
|
66
|
-
log_js_1.default.write(c.green(`Step 5. Build project: Done!`), { cache: true });
|
|
67
|
-
console.log((0, welcomeMessage_js_1.default)(options.projectPath));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function createDirIfNotExists(dir) {
|
|
71
|
-
if (!fs.existsSync(path.join(process.cwd(), dir))) {
|
|
72
|
-
fs.mkdirSync(path.join(process.cwd(), dir), { recursive: true });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function mergePackageJsonField(field, boilerplatePackagejson, userPackagejson) {
|
|
76
|
-
userPackagejson[field] ||= {};
|
|
77
|
-
userPackagejson[field] = {
|
|
78
|
-
...userPackagejson[field],
|
|
79
|
-
...boilerplatePackagejson[field],
|
|
80
|
-
};
|
|
81
|
-
userPackagejson[field] = (0, filterObjectByKey_js_1.default)(userPackagejson[field], Object.keys(userPackagejson[field]).sort());
|
|
82
|
-
}
|
|
83
|
-
function testEnv() {
|
|
84
|
-
return process.env.NODE_ENV === 'test';
|
|
85
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Logger = void 0;
|
|
4
|
-
class Logger {
|
|
5
|
-
cache = [];
|
|
6
|
-
write(text, { cache = false } = {}) {
|
|
7
|
-
console.log(text);
|
|
8
|
-
if (cache)
|
|
9
|
-
this.cache.push(text);
|
|
10
|
-
}
|
|
11
|
-
restoreCache(preRestoreContent) {
|
|
12
|
-
this.clear();
|
|
13
|
-
if (preRestoreContent)
|
|
14
|
-
this.write(preRestoreContent);
|
|
15
|
-
this.cache.forEach(str => {
|
|
16
|
-
this.write(str);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
clear() {
|
|
20
|
-
console.clear();
|
|
21
|
-
// @ts-expect-error this works fine with no args
|
|
22
|
-
process.stdout.clearLine();
|
|
23
|
-
process.stdout.cursorTo(0);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
exports.Logger = Logger;
|
|
27
|
-
const log = new Logger();
|
|
28
|
-
exports.default = log;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = logo;
|
|
4
|
-
exports.basicLogo = basicLogo;
|
|
5
|
-
const colors = require("colorette");
|
|
6
|
-
function logo() {
|
|
7
|
-
return (colors.bgMagentaBright(colors.black(`
|
|
8
|
-
,▄█▄
|
|
9
|
-
]█▄▄ ╓█████▌
|
|
10
|
-
▐██████▄ ▄█████▓╣█
|
|
11
|
-
║████████▄, , ,,▄,▄▄▄▓██████╬╬╣╣▌
|
|
12
|
-
╚███╣██████████▓▓▓▓██████████╩╠╬▓
|
|
13
|
-
╙█╬╬╬▓███████████████████████▒▓▌ `)) +
|
|
14
|
-
colors.bgMagentaBright(colors.black(`
|
|
15
|
-
╙▓█▓██████████████████████████
|
|
16
|
-
╚██████▀███████████`) +
|
|
17
|
-
colors.greenBright(`╩█▓▌`) +
|
|
18
|
-
colors.black(`▐▓████▄
|
|
19
|
-
'║█████`) +
|
|
20
|
-
colors.greenBright(`\`╣█Γ║`) +
|
|
21
|
-
colors.black(`████████▄▄φ▓█████▌
|
|
22
|
-
║█████████████████████▓█████▌
|
|
23
|
-
█████████████▓▓████████████ `)) +
|
|
24
|
-
colors.bgMagentaBright(colors.black(`
|
|
25
|
-
║█████████████████████████
|
|
26
|
-
]█████████████████████████
|
|
27
|
-
,▓██████████████████████████
|
|
28
|
-
▓█████████████████████████████µ `)) +
|
|
29
|
-
colors.bgMagentaBright(colors.black(`
|
|
30
|
-
▐███████████████████████████████▄▄
|
|
31
|
-
║█████████████████████████████████╬╬╣▓
|
|
32
|
-
,╔╦║███████████████████████████████████▓╬╬╣
|
|
33
|
-
,≥≥⌠░░░╠▓████████████████████████████████████▓▓
|
|
34
|
-
,;=-',▄█████████████████████████████████████████▓ `)) +
|
|
35
|
-
colors.bgGreen(colors.magenta(`
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
██████╗ ███████╗██╗ ██╗ ██████╗██╗ ██╗██╗ ██████╗
|
|
40
|
-
██╔══██╗██╔════╝╚██╗ ██╔╝██╔════╝██║ ██║██║██╔════╝
|
|
41
|
-
██████╔╝███████╗ ╚████╔╝ ██║ ███████║██║██║
|
|
42
|
-
██╔═══╝ ╚════██║ ╚██╔╝ ██║ ██╔══██║██║██║
|
|
43
|
-
██║ ███████║ ██║ ╚██████╗██║ ██║██║╚██████╗
|
|
44
|
-
╚═╝ ╚══════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═════╝
|
|
45
|
-
|
|
46
|
-
`)));
|
|
47
|
-
}
|
|
48
|
-
function basicLogo() {
|
|
49
|
-
return (`
|
|
50
|
-
,▄█▄
|
|
51
|
-
]█▄▄ ╓█████▌
|
|
52
|
-
▐██████▄ ▄█████▓╣█
|
|
53
|
-
║████████▄, , ,,▄,▄▄▄▓██████╬╬╣╣▌
|
|
54
|
-
╚███╣██████████▓▓▓▓██████████╩╠╬▓
|
|
55
|
-
╙█╬╬╬▓███████████████████████▒▓▌
|
|
56
|
-
╙▓█▓██████████████████████████
|
|
57
|
-
╚██████▀███████████╩█▓▌▐▓████▄
|
|
58
|
-
'║█████\`╣█Γ║████████▄▄φ▓█████▌
|
|
59
|
-
║█████████████████████▓█████▌
|
|
60
|
-
█████████████▓▓████████████
|
|
61
|
-
║█████████████████████████
|
|
62
|
-
]█████████████████████████
|
|
63
|
-
,▓██████████████████████████
|
|
64
|
-
▓█████████████████████████████µ
|
|
65
|
-
▐███████████████████████████████▄▄
|
|
66
|
-
║█████████████████████████████████╬╬╣▓
|
|
67
|
-
,╔╦║███████████████████████████████████▓╬╬╣
|
|
68
|
-
,≥≥⌠░░░╠▓████████████████████████████████████▓▓
|
|
69
|
-
,;=-',▄█████████████████████████████████████████▓
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
██████╗ ███████╗██╗ ██╗ ██████╗██╗ ██╗██╗ ██████╗
|
|
74
|
-
██╔══██╗██╔════╝╚██╗ ██╔╝██╔════╝██║ ██║██║██╔════╝
|
|
75
|
-
██████╔╝███████╗ ╚████╔╝ ██║ ███████║██║██║
|
|
76
|
-
██╔═══╝ ╚════██║ ╚██╔╝ ██║ ██╔══██║██║██║
|
|
77
|
-
██║ ███████║ ██║ ╚██████╗██║ ██║██║╚██████╗
|
|
78
|
-
╚═╝ ╚══════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═════╝
|
|
79
|
-
|
|
80
|
-
`);
|
|
81
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cliDefaultFactoriesPath = exports.cliDefaultModelSpecsPath = exports.cliDefaultServicesPath = exports.cliDefaultSerializersPath = exports.cliDefaultModelsPath = exports.cliDefaultTypesPath = exports.cliDefaultDbPath = exports.cliDefaultConfigPath = exports.cliDefaultProjectPath = exports.cliPrimaryKeyTypes = void 0;
|
|
4
|
-
exports.cliPrimaryKeyTypes = ['bigserial', 'serial', 'uuid'];
|
|
5
|
-
exports.cliDefaultProjectPath = '.';
|
|
6
|
-
exports.cliDefaultConfigPath = 'src/conf.js';
|
|
7
|
-
exports.cliDefaultDbPath = 'src/db.js';
|
|
8
|
-
exports.cliDefaultTypesPath = 'src/types.js';
|
|
9
|
-
exports.cliDefaultModelsPath = 'src/app/models.js';
|
|
10
|
-
exports.cliDefaultSerializersPath = 'src/app/serializers.js';
|
|
11
|
-
exports.cliDefaultServicesPath = 'src/app/services.js';
|
|
12
|
-
exports.cliDefaultModelSpecsPath = 'spec/uspec/models.js';
|
|
13
|
-
exports.cliDefaultFactoriesPath = 'spec/factories.js';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const readline = require("readline");
|
|
4
|
-
const input = process.stdin;
|
|
5
|
-
class Prompt {
|
|
6
|
-
question;
|
|
7
|
-
cb = null;
|
|
8
|
-
constructor(question) {
|
|
9
|
-
this.question = question;
|
|
10
|
-
}
|
|
11
|
-
async run() {
|
|
12
|
-
this.init();
|
|
13
|
-
return new Promise(accept => {
|
|
14
|
-
this.cb = accept;
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
init() {
|
|
18
|
-
const rl = readline.createInterface({
|
|
19
|
-
input: process.stdin,
|
|
20
|
-
output: process.stdout,
|
|
21
|
-
});
|
|
22
|
-
rl.question(this.question + '\n', res => {
|
|
23
|
-
this.cb?.(res);
|
|
24
|
-
rl.close();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
close = () => {
|
|
28
|
-
input.setRawMode(false);
|
|
29
|
-
input.pause();
|
|
30
|
-
process.exit(0);
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
exports.default = Prompt;
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const colors = require("colorette");
|
|
4
|
-
const readline = require("readline");
|
|
5
|
-
const input = process.stdin;
|
|
6
|
-
const output = process.stdout;
|
|
7
|
-
let firstCallComplete = false;
|
|
8
|
-
class Select {
|
|
9
|
-
question;
|
|
10
|
-
selectIndex = 0;
|
|
11
|
-
options;
|
|
12
|
-
selector = '>';
|
|
13
|
-
isFirstTimeShowMenu = true;
|
|
14
|
-
cb = null;
|
|
15
|
-
constructor(question, options) {
|
|
16
|
-
this.question = question;
|
|
17
|
-
this.options = options;
|
|
18
|
-
}
|
|
19
|
-
async run() {
|
|
20
|
-
this.init();
|
|
21
|
-
return new Promise(accept => {
|
|
22
|
-
this.cb = accept;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
keyPressedHandler(_, key) {
|
|
26
|
-
if (key) {
|
|
27
|
-
const optionLength = this.options.length - 1;
|
|
28
|
-
if (key.name === 'down' && this.selectIndex < optionLength) {
|
|
29
|
-
this.selectIndex += 1;
|
|
30
|
-
this.createOptionMenu();
|
|
31
|
-
}
|
|
32
|
-
else if (key.name === 'up' && this.selectIndex > 0) {
|
|
33
|
-
this.selectIndex -= 1;
|
|
34
|
-
this.createOptionMenu();
|
|
35
|
-
}
|
|
36
|
-
else if (key.name === 'return') {
|
|
37
|
-
this.cb?.(this.options[this.selectIndex]);
|
|
38
|
-
input.removeAllListeners('keypress');
|
|
39
|
-
if (firstCallComplete) {
|
|
40
|
-
output.write('\n');
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
firstCallComplete = true;
|
|
44
|
-
}
|
|
45
|
-
input.setRawMode(false);
|
|
46
|
-
input.pause();
|
|
47
|
-
}
|
|
48
|
-
else if (key.name === 'escape' || (key.name === 'c' && key.ctrl)) {
|
|
49
|
-
this.close();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
ansiEraseLines(count) {
|
|
54
|
-
//adapted from sindresorhus ansi-escape module
|
|
55
|
-
const ESC = '\u001B[';
|
|
56
|
-
const eraseLine = ESC + '2K';
|
|
57
|
-
const cursorUp = (count = 1) => ESC + count + 'A';
|
|
58
|
-
const cursorLeft = ESC + 'G';
|
|
59
|
-
let clear = '';
|
|
60
|
-
for (let i = 0; i < count; i++) {
|
|
61
|
-
clear += eraseLine + (i < count - 1 ? cursorUp() : '');
|
|
62
|
-
}
|
|
63
|
-
if (count) {
|
|
64
|
-
clear += cursorLeft;
|
|
65
|
-
}
|
|
66
|
-
return clear;
|
|
67
|
-
}
|
|
68
|
-
init() {
|
|
69
|
-
console.log(this.question);
|
|
70
|
-
readline.emitKeypressEvents(input);
|
|
71
|
-
this.start();
|
|
72
|
-
}
|
|
73
|
-
start() {
|
|
74
|
-
//setup the input for reading
|
|
75
|
-
input.setRawMode(true);
|
|
76
|
-
input.resume();
|
|
77
|
-
input.on('keypress', (event, key) => this.keyPressedHandler(event, key));
|
|
78
|
-
if (this.selectIndex >= 0) {
|
|
79
|
-
this.createOptionMenu();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
close = () => {
|
|
83
|
-
input.setRawMode(false);
|
|
84
|
-
input.pause();
|
|
85
|
-
process.exit(0);
|
|
86
|
-
};
|
|
87
|
-
getPadding(num = 10) {
|
|
88
|
-
let text = ' ';
|
|
89
|
-
for (let i = 0; i < num; i++) {
|
|
90
|
-
text += ' ';
|
|
91
|
-
}
|
|
92
|
-
return text;
|
|
93
|
-
}
|
|
94
|
-
createOptionMenu() {
|
|
95
|
-
const optionLength = this.options.length;
|
|
96
|
-
if (this.isFirstTimeShowMenu) {
|
|
97
|
-
this.isFirstTimeShowMenu = false;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
output.write(this.ansiEraseLines(optionLength));
|
|
101
|
-
}
|
|
102
|
-
const padding = this.getPadding(0);
|
|
103
|
-
const cursor = colors.magenta(this.selector);
|
|
104
|
-
for (let i = 0; i < optionLength; i++) {
|
|
105
|
-
const selectedOption = i === this.selectIndex
|
|
106
|
-
? `${cursor} ${this.options[i]}`
|
|
107
|
-
: `${cursor.replace(/.*/, ' ')} ${this.options[i]}`;
|
|
108
|
-
const ending = i !== optionLength - 1 ? '\n' : '';
|
|
109
|
-
output.write(padding + selectedOption + ending);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
exports.default = Select;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = sspawn;
|
|
4
|
-
exports.ssspawn = ssspawn;
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
|
-
function sspawn(command, opts = {}) {
|
|
7
|
-
return new Promise((accept, reject) => {
|
|
8
|
-
ssspawn(command, opts).on('close', code => {
|
|
9
|
-
if (code !== 0)
|
|
10
|
-
reject(code);
|
|
11
|
-
accept({});
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function ssspawn(command, opts = {}) {
|
|
16
|
-
return (0, child_process_1.spawn)(command, {
|
|
17
|
-
stdio: 'inherit',
|
|
18
|
-
shell: true,
|
|
19
|
-
...opts,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = welcomeMessage;
|
|
4
|
-
const c = require("colorette");
|
|
5
|
-
function welcomeMessage(appName) {
|
|
6
|
-
return `
|
|
7
|
-
${c.green(c.bold(c.italic(`Welcome to Dream! \n cd into ${c.magentaBright(appName)} to get started`)))}
|
|
8
|
-
|
|
9
|
-
${c.magenta(`to create a database,`)}
|
|
10
|
-
${c.magenta(`$ NODE_ENV=development yarn dream db:create`)}
|
|
11
|
-
${c.magenta(`$ NODE_ENV=test yarn dream db:create`)}
|
|
12
|
-
|
|
13
|
-
${c.magentaBright(`to migrate a database,`)}
|
|
14
|
-
${c.magentaBright(`$ NODE_ENV=development yarn dream db:migrate`)}
|
|
15
|
-
${c.magentaBright(`$ NODE_ENV=test yarn dream db:migrate`)}
|
|
16
|
-
|
|
17
|
-
${c.redBright(`to rollback a database,`)}
|
|
18
|
-
${c.redBright(`$ NODE_ENV=development yarn dream db:rollback`)}
|
|
19
|
-
${c.redBright(`$ NODE_ENV=test yarn dream db:rollback --step=1`)}
|
|
20
|
-
|
|
21
|
-
${c.blueBright(`to drop a database,`)}
|
|
22
|
-
${c.blueBright(`$ NODE_ENV=development yarn dream db:drop`)}
|
|
23
|
-
${c.blueBright(`$ NODE_ENV=test yarn dream db:drop`)}
|
|
24
|
-
|
|
25
|
-
# NOTE: doing it this way, you will still need to
|
|
26
|
-
# plug the routes manually in your api/src/app/conf/routes.ts file
|
|
27
|
-
|
|
28
|
-
${c.greenBright(`to create a model`)}
|
|
29
|
-
${c.greenBright(`$ yarn dream g:model user organization:belongs_to likes_chalupas:boolean some_id:uuid`)}
|
|
30
|
-
|
|
31
|
-
${c.yellow(`to create a migration`)}
|
|
32
|
-
${c.yellow(`$ yarn dream g:migration create-users`)}
|
|
33
|
-
|
|
34
|
-
${c.magentaBright(`to run unit tests,`)}
|
|
35
|
-
${c.magentaBright(`$ yarn dream uspec`)}
|
|
36
|
-
|
|
37
|
-
# NOTE: before you get started, be sure to visit your ${c.magenta('.env')} and ${c.magenta('.env.test')}
|
|
38
|
-
# files and make sure they have database credentials set correctly.
|
|
39
|
-
# you can see conf/dream.ts to see how those credentials are used.
|
|
40
|
-
`;
|
|
41
|
-
}
|