@contember/cli 1.1.0-alpha.1 → 1.1.0-alpha.4
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/Dockerfile +1 -0
- package/build.sh +2 -2
- package/dist/src/commands/migrations/MigrationAmendCommand.d.ts.map +1 -1
- package/dist/src/commands/migrations/MigrationAmendCommand.js +2 -2
- package/dist/src/commands/migrations/MigrationAmendCommand.js.map +1 -1
- package/dist/src/commands/migrations/MigrationDescribeCommand.js +1 -1
- package/dist/src/commands/migrations/MigrationDescribeCommand.js.map +1 -1
- package/dist/src/commands/migrations/MigrationDiffCommand.d.ts.map +1 -1
- package/dist/src/commands/migrations/MigrationDiffCommand.js +2 -2
- package/dist/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
- package/dist/src/commands/migrations/MigrationValidationHelper.js +1 -1
- package/dist/src/commands/migrations/MigrationValidationHelper.js.map +1 -1
- package/dist/src/commands/project/ProjectPrintSchemaCommand.d.ts.map +1 -1
- package/dist/src/commands/project/ProjectPrintSchemaCommand.js +2 -2
- package/dist/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
- package/dist/src/commands/project/ProjectValidateCommand.d.ts.map +1 -1
- package/dist/src/commands/project/ProjectValidateCommand.js +4 -5
- package/dist/src/commands/project/ProjectValidateCommand.js.map +1 -1
- package/dist/src/run.js +0 -7
- package/dist/src/run.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/utils/migrations.js +1 -1
- package/dist/src/utils/migrations.js.map +1 -1
- package/dist/src/utils/project.d.ts +4 -0
- package/dist/src/utils/project.d.ts.map +1 -0
- package/dist/src/utils/project.js +44 -0
- package/dist/src/utils/project.js.map +1 -0
- package/esbuild.js +1 -1
- package/package.json +14 -14
- package/src/commands/migrations/MigrationAmendCommand.ts +2 -3
- package/src/commands/migrations/MigrationDescribeCommand.ts +1 -1
- package/src/commands/migrations/MigrationDiffCommand.ts +2 -3
- package/src/commands/migrations/MigrationValidationHelper.ts +1 -1
- package/src/commands/project/ProjectPrintSchemaCommand.ts +2 -3
- package/src/commands/project/ProjectValidateCommand.ts +3 -6
- package/src/run.ts +3 -9
- package/src/utils/migrations.ts +1 -1
- package/src/utils/project.ts +23 -0
|
@@ -21,7 +21,7 @@ exports.getMigrationByName = getMigrationByName;
|
|
|
21
21
|
const findMigration = (migrations, version) => migrations.find(it => schema_migrations_1.MigrationVersionHelper.extractVersion(it.version) === schema_migrations_1.MigrationVersionHelper.extractVersion(version)) || null;
|
|
22
22
|
exports.findMigration = findMigration;
|
|
23
23
|
const printMigrationDescription = async function (migrationsDescriber, schema, migration, options) {
|
|
24
|
-
const description = await migrationsDescriber.describeModifications(schema, migration);
|
|
24
|
+
const description = await migrationsDescriber.describeModifications(schema, migration, 'system'); // schema name cannot be determined
|
|
25
25
|
description.forEach(({ modification, sql, description }) => {
|
|
26
26
|
if (options.sqlOnly) {
|
|
27
27
|
console.log(sql);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../../src/utils/migrations.ts"],"names":[],"mappings":";;;;;;AAAA,oEAOqC;AACrC,kDAAyB;AAEzB,8DAAoC;AACpC,+CAA2C;AAEpC,MAAM,kBAAkB,GAAG,KAAK,EAAE,kBAAsC,EAA6B,EAAE;IAC7G,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,aAAa,EAAE,CAAA;IAC3D,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACxE,CAAC,CAAA;AAHY,QAAA,kBAAkB,sBAG9B;AACM,MAAM,kBAAkB,GAAG,KAAK,EACtC,kBAAsC,EACtC,OAAe,EACa,EAAE;IAC9B,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,aAAa,EAAE,CAAA;IAC3D,OAAO,IAAA,qBAAa,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,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/utils/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAK1C,eAAO,MAAM,UAAU,YAAmB,OAAO,KAAG,QAAQ,MAAM,CAgBjE,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.loadSchema = void 0;
|
|
23
|
+
const esbuild = __importStar(require("esbuild"));
|
|
24
|
+
const path_1 = require("path");
|
|
25
|
+
const vm2_1 = require("vm2");
|
|
26
|
+
const loadSchema = async (project) => {
|
|
27
|
+
const response = await esbuild.build({
|
|
28
|
+
entryPoints: [(0, path_1.join)(project.apiDir, 'index.ts')],
|
|
29
|
+
platform: 'node',
|
|
30
|
+
bundle: true,
|
|
31
|
+
treeShaking: true,
|
|
32
|
+
write: false,
|
|
33
|
+
external: ['@contember/admin', 'react', 'react/jsx-runtime'],
|
|
34
|
+
});
|
|
35
|
+
const bundledJs = response.outputFiles[0].text;
|
|
36
|
+
const vm = new vm2_1.NodeVM({
|
|
37
|
+
require: {
|
|
38
|
+
builtin: ['*'],
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return (await vm.run(bundledJs)).default;
|
|
42
|
+
};
|
|
43
|
+
exports.loadSchema = loadSchema;
|
|
44
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../src/utils/project.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,iDAAkC;AAClC,+BAA2B;AAC3B,6BAA4B;AAErB,MAAM,UAAU,GAAG,KAAK,EAAE,OAAgB,EAAmB,EAAE;IACrE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC;QACpC,WAAW,EAAE,CAAC,IAAA,WAAI,EAAC,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC/C,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;QACjB,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE,CAAC,kBAAkB,EAAE,OAAO,EAAE,mBAAmB,CAAC;KAC5D,CAAC,CAAA;IACF,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC9C,MAAM,EAAE,GAAG,IAAI,YAAM,CAAC;QACrB,OAAO,EAAE;YACR,OAAO,EAAE,CAAC,GAAG,CAAC;SACd;KACD,CAAC,CAAA;IACF,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAA;AACzC,CAAC,CAAA;AAhBY,QAAA,UAAU,cAgBtB"}
|
package/esbuild.js
CHANGED
|
@@ -8,7 +8,7 @@ esbuild.build({
|
|
|
8
8
|
sourcemap: 'external',
|
|
9
9
|
outfile: './dist/run.js',
|
|
10
10
|
plugins: [resolvePlugin],
|
|
11
|
-
external: ['pg-native', 'electron', '
|
|
11
|
+
external: ['pg-native', 'electron', 'esbuild', 'vm2'],
|
|
12
12
|
}).catch(e => {
|
|
13
13
|
console.error(e)
|
|
14
14
|
process.exit(1)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/cli",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"contember": "./dist/src/run.js"
|
|
@@ -9,23 +9,24 @@
|
|
|
9
9
|
"test": "echo 'No tests'"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@types/
|
|
12
|
+
"@types/fs-extra": "^9.0.3",
|
|
13
13
|
"@types/js-yaml": "^4.0.1",
|
|
14
|
-
"@types/
|
|
14
|
+
"@types/prompts": "^2.0.1"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@contember/cli-common": "^1.1.0-alpha.
|
|
18
|
-
"@contember/config-loader": "^1.1.0-alpha.
|
|
19
|
-
"@contember/database-migrations": "^1.1.0-alpha.
|
|
20
|
-
"@contember/dic": "^1.1.0-alpha.
|
|
21
|
-
"@contember/engine-content-api": "^1.1.0-alpha.
|
|
22
|
-
"@contember/schema": "^1.1.0-alpha.
|
|
23
|
-
"@contember/schema-definition": "^1.1.0-alpha.
|
|
24
|
-
"@contember/schema-migrations": "^1.1.0-alpha.
|
|
25
|
-
"@contember/schema-utils": "^1.1.0-alpha.
|
|
17
|
+
"@contember/cli-common": "^1.1.0-alpha.4",
|
|
18
|
+
"@contember/config-loader": "^1.1.0-alpha.4",
|
|
19
|
+
"@contember/database-migrations": "^1.1.0-alpha.4",
|
|
20
|
+
"@contember/dic": "^1.1.0-alpha.4",
|
|
21
|
+
"@contember/engine-content-api": "^1.1.0-alpha.4",
|
|
22
|
+
"@contember/schema": "^1.1.0-alpha.4",
|
|
23
|
+
"@contember/schema-definition": "^1.1.0-alpha.4",
|
|
24
|
+
"@contember/schema-migrations": "^1.1.0-alpha.4",
|
|
25
|
+
"@contember/schema-utils": "^1.1.0-alpha.4",
|
|
26
26
|
"@graphql-tools/merge": "^6.2.14",
|
|
27
27
|
"chalk": "^4.1.0",
|
|
28
28
|
"chalk-table": "^1.0.2",
|
|
29
|
+
"esbuild": "^0.14.14",
|
|
29
30
|
"get-port": "^5.0.0",
|
|
30
31
|
"graphql": "^15.4.0",
|
|
31
32
|
"graphql-request": "^3.3.0",
|
|
@@ -33,8 +34,7 @@
|
|
|
33
34
|
"node-fetch": "^2.6.1",
|
|
34
35
|
"pg": "^8.5.0",
|
|
35
36
|
"prompts": "^2.2.1",
|
|
36
|
-
"
|
|
37
|
-
"typescript": "^4.3.5",
|
|
37
|
+
"vm2": "^3.9.9",
|
|
38
38
|
"yawn-yaml": "^1.5.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
2
|
-
import { Schema } from '@contember/schema'
|
|
3
2
|
import { printValidationErrors } from '../../utils/schema'
|
|
4
3
|
import { InvalidSchemaException } from '@contember/schema-migrations'
|
|
5
4
|
import { executeCreateMigrationCommand } from './MigrationCreateHelper'
|
|
@@ -14,6 +13,7 @@ import { resolveSystemApiClient } from './SystemApiClientResolver'
|
|
|
14
13
|
import prompts from 'prompts'
|
|
15
14
|
import { emptySchema } from '@contember/schema-utils'
|
|
16
15
|
import { validateMigrations } from './MigrationValidationHelper'
|
|
16
|
+
import { loadSchema } from '../../utils/project'
|
|
17
17
|
|
|
18
18
|
type Args = {
|
|
19
19
|
project: string
|
|
@@ -68,8 +68,7 @@ export class MigrationAmendCommand extends Command<Args, Options> {
|
|
|
68
68
|
if (status.migrationsToExecute.length > 0) {
|
|
69
69
|
throw `Some migrations are not executed. Unable to amend.`
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
const schema: Schema = require(project.apiDir).default
|
|
71
|
+
const schema = await loadSchema(project)
|
|
73
72
|
try {
|
|
74
73
|
const initialSchema = await schemaVersionBuilder.buildSchema()
|
|
75
74
|
const intermediateResult = await migrationCreator.prepareMigration(initialSchema, schema, '')
|
|
@@ -22,7 +22,7 @@ let printMigrationDescription = async function (
|
|
|
22
22
|
migration: Migration,
|
|
23
23
|
options: { sqlOnly: boolean; noSql: boolean },
|
|
24
24
|
) {
|
|
25
|
-
const description = await migrationsDescriber.describeModifications(schema, migration)
|
|
25
|
+
const description = await migrationsDescriber.describeModifications(schema, migration, 'system') // schema name cannot be determined here
|
|
26
26
|
description.forEach(({ modification, sql, description }) => {
|
|
27
27
|
if (options.sqlOnly) {
|
|
28
28
|
if (sql.trim()) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
2
|
-
import { Schema } from '@contember/schema'
|
|
3
2
|
import { printValidationErrors } from '../../utils/schema'
|
|
4
3
|
import { InvalidSchemaException } from '@contember/schema-migrations'
|
|
5
4
|
import { configureCreateMigrationCommand, executeCreateMigrationCommand } from './MigrationCreateHelper'
|
|
@@ -9,6 +8,7 @@ import prompts from 'prompts'
|
|
|
9
8
|
import { interactiveResolveApiToken, TenantClient } from '../../utils/tenant'
|
|
10
9
|
import { interactiveResolveInstanceEnvironmentFromInput } from '../../utils/instance'
|
|
11
10
|
import { SystemClient } from '../../utils/system'
|
|
11
|
+
import { loadSchema } from '../../utils/project'
|
|
12
12
|
|
|
13
13
|
type Args = {
|
|
14
14
|
project: string
|
|
@@ -42,8 +42,7 @@ export class MigrationDiffCommand extends Command<Args, Options> {
|
|
|
42
42
|
migrationCreator,
|
|
43
43
|
migrationDescriber,
|
|
44
44
|
}) => {
|
|
45
|
-
|
|
46
|
-
const schema: Schema = require(project.apiDir).default
|
|
45
|
+
const schema = await loadSchema(project)
|
|
47
46
|
try {
|
|
48
47
|
const migrationName = input.getArgument('migrationName')
|
|
49
48
|
const initialSchema = await schemaVersionBuilder.buildSchema()
|
|
@@ -13,7 +13,7 @@ export const validateMigrations = async (
|
|
|
13
13
|
for (const migration of await migrations) {
|
|
14
14
|
try {
|
|
15
15
|
// just a check that it does not fail
|
|
16
|
-
await describer.describeModifications(migratedSchema, migration)
|
|
16
|
+
await describer.describeModifications(migratedSchema, migration, 'system') // schema name not important here
|
|
17
17
|
|
|
18
18
|
migratedSchema = migrator.applyModifications(migratedSchema, migration.modifications, migration.formatVersion)
|
|
19
19
|
} catch (e) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
2
|
-
import { Schema } from '@contember/schema'
|
|
3
2
|
import { validateSchemaAndPrintErrors } from '../../utils/schema'
|
|
4
3
|
import { Workspace, validateProjectName } from '@contember/cli-common'
|
|
5
4
|
import {
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
} from '@contember/engine-content-api'
|
|
13
12
|
import { DocumentNode, printSchema } from 'graphql'
|
|
14
13
|
import { mergeSchemas } from '@graphql-tools/merge'
|
|
14
|
+
import { loadSchema } from '../../utils/project'
|
|
15
15
|
|
|
16
16
|
type Args = {
|
|
17
17
|
project: string
|
|
@@ -37,8 +37,7 @@ export class ProjectPrintSchemaCommand extends Command<Args, Options> {
|
|
|
37
37
|
|
|
38
38
|
validateProjectName(projectName)
|
|
39
39
|
const project = await workspace.projects.getProject(projectName, { fuzzy: true })
|
|
40
|
-
|
|
41
|
-
const schema: Schema = require(project.apiDir).default
|
|
40
|
+
const schema = await loadSchema(project)
|
|
42
41
|
if (!validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:')) {
|
|
43
42
|
return 1
|
|
44
43
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Command, CommandConfiguration, Input } from '@contember/cli-common'
|
|
1
|
+
import { Command, CommandConfiguration, Input, validateProjectName, Workspace } from '@contember/cli-common'
|
|
2
2
|
import { MigrationsContainerFactory } from '../../MigrationsContainer'
|
|
3
|
-
import { Schema } from '@contember/schema'
|
|
4
3
|
import { validateSchemaAndPrintErrors } from '../../utils/schema'
|
|
5
4
|
import { emptySchema } from '@contember/schema-utils'
|
|
6
|
-
import { Workspace, validateProjectName } from '@contember/cli-common'
|
|
7
5
|
import { validateMigrations } from '../migrations/MigrationValidationHelper'
|
|
6
|
+
import { loadSchema } from '../../utils/project'
|
|
8
7
|
|
|
9
8
|
type Args = {
|
|
10
9
|
project: string
|
|
@@ -42,9 +41,7 @@ export class ProjectValidateCommand extends Command<Args, Options> {
|
|
|
42
41
|
container.migrationDescriber,
|
|
43
42
|
container.schemaMigrator,
|
|
44
43
|
)
|
|
45
|
-
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
47
|
-
const schema: Schema = require(project.apiDir).default
|
|
44
|
+
const schema = await loadSchema(project)
|
|
48
45
|
projectValid = validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:') && projectValid
|
|
49
46
|
|
|
50
47
|
const builtSchema = await container.schemaVersionBuilder.buildSchema()
|
package/src/run.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { register } from 'ts-node'
|
|
3
2
|
import { Application, CommandManager, getPackageVersion } from '@contember/cli-common'
|
|
4
3
|
import {
|
|
5
4
|
CreateApiKeyCommand,
|
|
@@ -18,14 +17,9 @@ import {
|
|
|
18
17
|
SignInCommand,
|
|
19
18
|
VersionCommand,
|
|
20
19
|
WorkspaceUpdateApiCommand,
|
|
21
|
-
} from './commands'
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
compilerOptions: {
|
|
25
|
-
experimentalDecorators: true,
|
|
26
|
-
module: 'commonjs',
|
|
27
|
-
},
|
|
28
|
-
})
|
|
20
|
+
} from './commands';
|
|
21
|
+
|
|
22
|
+
(async () => {
|
|
29
23
|
const diffCommandFactory = () => new MigrationDiffCommand()
|
|
30
24
|
const migrationsDescribeFactory = () => new MigrationDescribeCommand()
|
|
31
25
|
const commandManager = new CommandManager({
|
package/src/utils/migrations.ts
CHANGED
|
@@ -34,7 +34,7 @@ export const printMigrationDescription = async function (
|
|
|
34
34
|
migration: Migration,
|
|
35
35
|
options: { sqlOnly?: boolean; noSql?: boolean },
|
|
36
36
|
) {
|
|
37
|
-
const description = await migrationsDescriber.describeModifications(schema, migration)
|
|
37
|
+
const description = await migrationsDescriber.describeModifications(schema, migration, 'system') // schema name cannot be determined
|
|
38
38
|
description.forEach(({ modification, sql, description }) => {
|
|
39
39
|
if (options.sqlOnly) {
|
|
40
40
|
console.log(sql)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Project } from '@contember/cli-common'
|
|
2
|
+
import { Schema } from '@contember/schema'
|
|
3
|
+
import * as esbuild from 'esbuild'
|
|
4
|
+
import { join } from 'path'
|
|
5
|
+
import { NodeVM } from 'vm2'
|
|
6
|
+
|
|
7
|
+
export const loadSchema = async (project: Project): Promise<Schema> => {
|
|
8
|
+
const response = await esbuild.build({
|
|
9
|
+
entryPoints: [join(project.apiDir, 'index.ts')],
|
|
10
|
+
platform: 'node',
|
|
11
|
+
bundle: true,
|
|
12
|
+
treeShaking: true,
|
|
13
|
+
write: false,
|
|
14
|
+
external: ['@contember/admin', 'react', 'react/jsx-runtime'],
|
|
15
|
+
})
|
|
16
|
+
const bundledJs = response.outputFiles[0].text
|
|
17
|
+
const vm = new NodeVM({
|
|
18
|
+
require: {
|
|
19
|
+
builtin: ['*'],
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
return (await vm.run(bundledJs)).default
|
|
23
|
+
}
|