@rvoh/dream 0.32.4 → 0.33.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/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/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/docs/assets/search.js +1 -1
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/Decorators.html +19 -19
- package/docs/classes/Dream.html +126 -126
- package/docs/classes/DreamApplication.html +4 -5
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamDbConnection.html +2 -2
- 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 +3 -3
- package/docs/classes/NonLoadedAssociation.html +3 -3
- package/docs/classes/Query.html +50 -50
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/ValidationError.html +3 -3
- 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/db.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/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- 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/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- 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 +2 -5
- 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/dist/types/src/{global-cli/helpers/autogeneratedFileMessage.d.ts → helpers/cli/autoGeneratedFileDisclaimer.d.ts} +0 -0
|
@@ -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
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = initDreamApp;
|
|
4
|
-
const initDreamAppIntoExistingProject_js_1 = require("./helpers/initDreamAppIntoExistingProject.js");
|
|
5
|
-
const primaryKeyTypes_js_1 = require("./helpers/primaryKeyTypes.js");
|
|
6
|
-
const prompt_js_1 = require("./helpers/prompt.js");
|
|
7
|
-
const select_js_1 = require("./helpers/select.js");
|
|
8
|
-
async function initDreamApp(options) {
|
|
9
|
-
if (!options.primaryKeyType || !primaryKeyTypes_js_1.cliPrimaryKeyTypes.includes(options.primaryKeyType)) {
|
|
10
|
-
const answer = await new select_js_1.default('what primary key type would you like to use?', primaryKeyTypes_js_1.cliPrimaryKeyTypes).run();
|
|
11
|
-
options.primaryKeyType = answer;
|
|
12
|
-
}
|
|
13
|
-
if (!options.projectPath) {
|
|
14
|
-
const answer = await new prompt_js_1.default(`Relative to the current directory, where would you like us to put your project? (defaults to the current directory)`).run();
|
|
15
|
-
if (process.env.DREAM_CORE_DEVELOPMENT === '1' && !answer) {
|
|
16
|
-
throw new Error(`
|
|
17
|
-
when in dream core development, you must provide an explicit project directory. If you do not specify it,
|
|
18
|
-
you risk accidentally overwriting all the root files in the dream directory.
|
|
19
|
-
`);
|
|
20
|
-
}
|
|
21
|
-
options.projectPath = answer || primaryKeyTypes_js_1.cliDefaultProjectPath;
|
|
22
|
-
}
|
|
23
|
-
if (!options.configPath) {
|
|
24
|
-
const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your config files? (defaults to ${primaryKeyTypes_js_1.cliDefaultConfigPath})`).run();
|
|
25
|
-
options.configPath = answer || primaryKeyTypes_js_1.cliDefaultConfigPath;
|
|
26
|
-
}
|
|
27
|
-
if (!options.modelsPath) {
|
|
28
|
-
const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your models? (defaults to ${primaryKeyTypes_js_1.cliDefaultModelsPath})`).run();
|
|
29
|
-
options.modelsPath = answer || primaryKeyTypes_js_1.cliDefaultModelsPath;
|
|
30
|
-
}
|
|
31
|
-
if (!options.serializersPath) {
|
|
32
|
-
const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your serializers? (defaults to ${primaryKeyTypes_js_1.cliDefaultSerializersPath})`).run();
|
|
33
|
-
options.serializersPath = answer || primaryKeyTypes_js_1.cliDefaultSerializersPath;
|
|
34
|
-
}
|
|
35
|
-
if (!options.servicesPath) {
|
|
36
|
-
const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your services? (defaults to ${primaryKeyTypes_js_1.cliDefaultServicesPath})`).run();
|
|
37
|
-
options.servicesPath = answer || primaryKeyTypes_js_1.cliDefaultServicesPath;
|
|
38
|
-
}
|
|
39
|
-
if (!options.dbPath) {
|
|
40
|
-
const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your db files? (defaults to ${primaryKeyTypes_js_1.cliDefaultDbPath})`).run();
|
|
41
|
-
options.dbPath = answer || primaryKeyTypes_js_1.cliDefaultDbPath;
|
|
42
|
-
}
|
|
43
|
-
if (!options.typesPath) {
|
|
44
|
-
const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your dream.ts and db.ts type files? (defaults to ${primaryKeyTypes_js_1.cliDefaultTypesPath})`).run();
|
|
45
|
-
options.typesPath = answer || primaryKeyTypes_js_1.cliDefaultTypesPath;
|
|
46
|
-
}
|
|
47
|
-
if (!options.modelSpecsPath) {
|
|
48
|
-
const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your model tests? (defaults to ${primaryKeyTypes_js_1.cliDefaultModelSpecsPath})`).run();
|
|
49
|
-
options.modelSpecsPath = answer || primaryKeyTypes_js_1.cliDefaultModelSpecsPath;
|
|
50
|
-
}
|
|
51
|
-
if (!options.factoriesPath) {
|
|
52
|
-
const answer = await new prompt_js_1.default(`Relative to your project root, where would you like us to put your factories? (defaults to ${primaryKeyTypes_js_1.cliDefaultFactoriesPath})`).run();
|
|
53
|
-
options.factoriesPath = answer || primaryKeyTypes_js_1.cliDefaultFactoriesPath;
|
|
54
|
-
}
|
|
55
|
-
await (0, initDreamAppIntoExistingProject_js_1.default)('dream app', options);
|
|
56
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = newDreamApp;
|
|
4
|
-
const fs = require("fs/promises");
|
|
5
|
-
const buildNewDreamApp_js_1 = require("./helpers/buildNewDreamApp.js");
|
|
6
|
-
async function newDreamApp(appName, options) {
|
|
7
|
-
const projectPath = `./${appName}`;
|
|
8
|
-
await fs.mkdir(projectPath);
|
|
9
|
-
await (0, buildNewDreamApp_js_1.default)(appName, projectPath, options);
|
|
10
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "module",
|
|
3
|
-
"name": "tbd",
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"main": "src/index.ts",
|
|
6
|
-
"author": "tbd",
|
|
7
|
-
"private": true,
|
|
8
|
-
"scripts": {
|
|
9
|
-
"dream": "yarn dreamts",
|
|
10
|
-
"dreamjs": "node --experimental-modules dist/test-app/cli/index.js",
|
|
11
|
-
"dreamts": "node --experimental-specifier-resolution=node --import=./bin/esm.js ./src/cli/index.ts",
|
|
12
|
-
"console": "node --experimental-specifier-resolution=node --import=./bin/esm.js ./src/conf/repl.ts",
|
|
13
|
-
"lint": "yarn run eslint --no-warn-ignored \"src/**/*.ts\" \"spec/**/*.ts\""
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@rvoh/dream": "1.0.0",
|
|
17
|
-
"@types/node": "^20.11.17",
|
|
18
|
-
"@types/pg": "^8.11.3",
|
|
19
|
-
"kysely-codegen": "^0.11.0",
|
|
20
|
-
"kysely": "^0.27.2",
|
|
21
|
-
"pg": "^8.11.3",
|
|
22
|
-
"winston": "^3.13.0"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@eslint/js": "=9.0.0",
|
|
26
|
-
"@rvoh/dream-spec-helpers": "1.0.0",
|
|
27
|
-
"@types/jest": "^29.5.12",
|
|
28
|
-
"@types/node": "^20.11.17",
|
|
29
|
-
"@types/pg": "^8.11.3",
|
|
30
|
-
"eslint": "=9.0.0",
|
|
31
|
-
"jest": "^29.7.0",
|
|
32
|
-
"luxon-jest-matchers": "^0.1.14",
|
|
33
|
-
"prettier": "^3.2.5",
|
|
34
|
-
"ts-jest": "^29.1.4",
|
|
35
|
-
"ts-node": "^10.9.2",
|
|
36
|
-
"typescript-eslint": "=7.18.0",
|
|
37
|
-
"typescript": "^5.4.5"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import DreamImporter from '../DreamImporter.js';
|
|
2
|
-
import globalServiceKeyFromPath from '../globalServiceKeyFromPath.js';
|
|
3
|
-
let _services;
|
|
4
|
-
export default async function importServices(servicesPath, serviceImportCb) {
|
|
5
|
-
if (_services)
|
|
6
|
-
return _services;
|
|
7
|
-
_services = {};
|
|
8
|
-
const serviceClasses = await DreamImporter.importServices(servicesPath, serviceImportCb);
|
|
9
|
-
for (const [servicePath, serviceClass] of serviceClasses) {
|
|
10
|
-
// we only want to register services within our app
|
|
11
|
-
// that are backgroundable, since the only purpose
|
|
12
|
-
// for keeping these indices is to be able to summon
|
|
13
|
-
// a service for backgrounding.
|
|
14
|
-
if (typeof serviceClass?.background === 'function' || typeof serviceClass?.schedule === 'function') {
|
|
15
|
-
const serviceKey = globalServiceKeyFromPath(servicePath, servicesPath);
|
|
16
|
-
if (typeof serviceClass['setGlobalName'] === 'function') {
|
|
17
|
-
serviceClass['setGlobalName'](serviceKey);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
serviceClass.globalName = serviceKey;
|
|
21
|
-
}
|
|
22
|
-
_services[serviceKey] = serviceClass;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return _services;
|
|
26
|
-
}
|
|
27
|
-
export function setCachedServices(services) {
|
|
28
|
-
_services = services;
|
|
29
|
-
}
|
|
30
|
-
export function getServicesOrFail() {
|
|
31
|
-
if (!_services)
|
|
32
|
-
throw new Error('Must call loadServices before calling getServicesOrFail');
|
|
33
|
-
return _services;
|
|
34
|
-
}
|
|
35
|
-
export function getServicesOrBlank() {
|
|
36
|
-
return _services || {};
|
|
37
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// nice reference for shell commands:
|
|
3
|
-
// https://www.freecodecamp.org/news/node-js-child-processes-everything-you-need-to-know-e69498fe970a/
|
|
4
|
-
// commanderjs docs:
|
|
5
|
-
// https://github.com/tj/commander.js#quick-start
|
|
6
|
-
import { Command } from 'commander';
|
|
7
|
-
import { cliDefaultConfigPath, cliDefaultDbPath, cliDefaultFactoriesPath, cliDefaultModelsPath, cliDefaultModelSpecsPath, cliDefaultProjectPath, cliDefaultSerializersPath, cliDefaultServicesPath, cliDefaultTypesPath, cliPrimaryKeyTypes, } from './helpers/primaryKeyTypes.js';
|
|
8
|
-
import initDreamApp from './init.js';
|
|
9
|
-
import newDreamApp from './new.js';
|
|
10
|
-
const program = new Command();
|
|
11
|
-
program
|
|
12
|
-
.command('new')
|
|
13
|
-
.description('creates a new dream app using the name provided')
|
|
14
|
-
.argument('<name>', 'name of the app you want to create')
|
|
15
|
-
.option('--primary-key-type <KEY_TYPE>', `One of: ${cliPrimaryKeyTypes.join(', ')}. The type of primary key to use by default when generating Dream models (can be changed on a model-by-model basis as needed in each migration file)`)
|
|
16
|
-
.option('--project-path <PATH>', 'the root of the project', cliDefaultProjectPath)
|
|
17
|
-
.option('--config-path <PATH>', 'the path from your project root to the config directory', cliDefaultConfigPath)
|
|
18
|
-
.option('--db-path <PATH>', 'the path from your project root to the db directory', cliDefaultDbPath)
|
|
19
|
-
.option('--types-path <PATH>', 'the path from your project root to the types directory', cliDefaultTypesPath)
|
|
20
|
-
.option('--models-path <PATH>', 'the path from your project root to the models directory', cliDefaultModelsPath)
|
|
21
|
-
.option('--serializers-path <PATH>', 'the path from your project root to the serializers directory', cliDefaultSerializersPath)
|
|
22
|
-
.option('--services-path <PATH>', 'the path from your project root to the services directory', cliDefaultServicesPath)
|
|
23
|
-
.option('--model-specs-path <PATH>', 'the path from your project root to the model specs directory', cliDefaultModelSpecsPath)
|
|
24
|
-
.option('--factories-path <PATH>', 'the path from your project root to the spec factories directory', cliDefaultFactoriesPath)
|
|
25
|
-
.action(async (name, options) => {
|
|
26
|
-
await newDreamApp(name, options);
|
|
27
|
-
});
|
|
28
|
-
program
|
|
29
|
-
.command('init')
|
|
30
|
-
.description('initialize a new dream app into your existing application')
|
|
31
|
-
.option('--primary-key-type <KEY_TYPE>', `One of: ${cliPrimaryKeyTypes.join(', ')}. The type of primary key to use by default when generating Dream models (can be changed on a model-by-model basis as needed in each migration file)`)
|
|
32
|
-
.option('--project-path <PATH>', 'the root of the project')
|
|
33
|
-
.option('--config-path <PATH>', 'the path from your project root to the config directory')
|
|
34
|
-
.option('--db-path <PATH>', 'the path from your project root to the db directory')
|
|
35
|
-
.option('--types-path <PATH>', 'the path from your project root to the types directory')
|
|
36
|
-
.option('--models-path <PATH>', 'the path from your project root to the models directory')
|
|
37
|
-
.option('--serializers-path <PATH>', 'the path from your project root to the serializers directory')
|
|
38
|
-
.option('--services-path <PATH>', 'the path from your project root to the services directory')
|
|
39
|
-
.option('--model-specs-path <PATH>', 'the path from your project root to the model specs directory')
|
|
40
|
-
.option('--factories-path <PATH>', 'the path from your project root to the spec factories directory')
|
|
41
|
-
.action(async (options) => {
|
|
42
|
-
await initDreamApp(options);
|
|
43
|
-
});
|
|
44
|
-
program.parse();
|