@abgov/nx-adsp 13.20.0 → 13.20.1
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/package.json +1 -5
- package/src/generators/dotnet-service/dotnet-service.js +34 -18
- package/src/generators/dotnet-service/dotnet-service.js.map +1 -1
- package/src/generators/dotnet-service/dotnet-service.spec.ts +40 -29
- package/src/generators/dotnet-service/files/Examples/HelloWorldConfiguration.cs__tmpl__ +2 -2
- package/src/generators/dotnet-service/files/Examples/HelloWorldEvent.cs__tmpl__ +9 -9
- package/src/generators/dotnet-service/files/Examples/ServiceRoles.cs__tmpl__ +1 -1
- package/src/generators/dotnet-service/files/Program.cs__tmpl__ +18 -18
- package/src/generators/dotnet-service/files/__projectName__.csproj__tmpl__ +16 -0
- package/src/generators/dotnet-service/nuget-files/NuGet.Config__tmpl__ +13 -0
- package/src/generators/dotnet-service/schema.d.ts +1 -0
- package/src/generators/dotnet-service/schema.json +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/nx-adsp",
|
|
3
|
-
"version": "13.20.
|
|
3
|
+
"version": "13.20.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"description": "Government of Alberta - Nx plugin for ADSP apps.",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@abgov/nx-oc": "^13.0.0-0",
|
|
14
|
-
"@nx-dotnet/core": "^3.0.0",
|
|
15
14
|
"@nx/angular": "^23.0.0",
|
|
16
15
|
"@nx/devkit": "^23.0.0",
|
|
17
16
|
"@nx/eslint": "^23.0.0",
|
|
@@ -22,9 +21,6 @@
|
|
|
22
21
|
"tslib": "^2.0.0"
|
|
23
22
|
},
|
|
24
23
|
"peerDependenciesMeta": {
|
|
25
|
-
"@nx-dotnet/core": {
|
|
26
|
-
"optional": true
|
|
27
|
-
},
|
|
28
24
|
"@nx/angular": {
|
|
29
25
|
"optional": true
|
|
30
26
|
},
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = default_1;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const nx_oc_1 = require("@abgov/nx-oc");
|
|
6
|
-
const generator_1 = require("@nx-dotnet/core/src/generators/app/generator");
|
|
7
|
-
const generator_2 = require("@nx-dotnet/core/src/generators/nuget-reference/generator");
|
|
8
6
|
const devkit_1 = require("@nx/devkit");
|
|
9
7
|
const path = require("path");
|
|
10
8
|
function normalizeOptions(host, options) {
|
|
@@ -18,30 +16,48 @@ function normalizeOptions(host, options) {
|
|
|
18
16
|
});
|
|
19
17
|
}
|
|
20
18
|
function addFiles(host, options) {
|
|
21
|
-
const templateOptions = Object.assign(Object.assign(Object.assign({}, options), options.adsp), { tmpl: '' });
|
|
19
|
+
const templateOptions = Object.assign(Object.assign(Object.assign(Object.assign({}, options), options.adsp), (0, devkit_1.names)(options.projectName)), { tmpl: '' });
|
|
22
20
|
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'files'), options.projectRoot, templateOptions);
|
|
23
21
|
}
|
|
22
|
+
function ensureNuGetConfig(host) {
|
|
23
|
+
if (!host.exists('NuGet.Config')) {
|
|
24
|
+
(0, devkit_1.generateFiles)(host, path.join(__dirname, 'nuget-files'), '.', { tmpl: '' });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
24
27
|
function default_1(host, options) {
|
|
25
28
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
if (!(0, nx_oc_1.hasDependency)(host, '@nx
|
|
27
|
-
throw new Error('nx
|
|
29
|
+
if (!(0, nx_oc_1.hasDependency)(host, '@nx/dotnet')) {
|
|
30
|
+
throw new Error('@nx/dotnet is required to generate dotnet service');
|
|
28
31
|
}
|
|
29
32
|
const normalizedOptions = yield normalizeOptions(host, options);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
(0, devkit_1.addProjectConfiguration)(host, normalizedOptions.projectName, {
|
|
34
|
+
root: normalizedOptions.projectRoot,
|
|
35
|
+
projectType: 'application',
|
|
36
|
+
sourceRoot: normalizedOptions.projectRoot,
|
|
37
|
+
targets: {
|
|
38
|
+
serve: {
|
|
39
|
+
executor: 'nx:run-commands',
|
|
40
|
+
options: {
|
|
41
|
+
command: 'dotnet run',
|
|
42
|
+
cwd: normalizedOptions.projectRoot,
|
|
43
|
+
},
|
|
44
|
+
configurations: {
|
|
45
|
+
production: {
|
|
46
|
+
command: 'dotnet run --configuration Release',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
tags: ['adsp:type:dotnet'],
|
|
38
52
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
(0, devkit_1.updateJson)(host, 'nx.json', (json) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
if (!((_a = json.plugins) === null || _a === void 0 ? void 0 : _a.includes('@nx/dotnet'))) {
|
|
56
|
+
json.plugins = [...((_b = json.plugins) !== null && _b !== void 0 ? _b : []), '@nx/dotnet'];
|
|
57
|
+
}
|
|
58
|
+
return json;
|
|
44
59
|
});
|
|
60
|
+
ensureNuGetConfig(host);
|
|
45
61
|
addFiles(host, normalizedOptions);
|
|
46
62
|
yield (0, nx_oc_1.deploymentGenerator)(host, Object.assign(Object.assign({}, normalizedOptions), { appType: 'dotnet', project: normalizedOptions.projectName }));
|
|
47
63
|
return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotnet-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/dotnet-service/dotnet-service.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"dotnet-service.js","sourceRoot":"","sources":["../../../../../../packages/nx-adsp/src/generators/dotnet-service/dotnet-service.ts"],"names":[],"mappings":";;AAuDA,4BA+CC;;AAtGD,wCAIsB;AACtB,uCAQoB;AACpB,6BAA6B;AAG7B,SAAe,gBAAgB,CAC7B,IAAU,EACV,OAAe;;QAEf,MAAM,WAAW,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;QACjD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,WAAW,EAAE,CAAC;QAEzE,MAAM,IAAI,GAAG,MAAM,IAAA,4BAAoB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEvD,uCACK,OAAO,KACV,WAAW;YACX,WAAW;YACX,IAAI,IACJ;IACJ,CAAC;CAAA;AAED,SAAS,QAAQ,CAAC,IAAU,EAAE,OAAyB;IACrD,MAAM,eAAe,+DAChB,OAAO,GACP,OAAO,CAAC,IAAI,GACZ,IAAA,cAAK,EAAC,OAAO,CAAC,WAAW,CAAC,KAC7B,IAAI,EAAE,EAAE,GACT,CAAC;IACF,IAAA,sBAAa,EACX,IAAI,EACJ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,WAAW,EACnB,eAAe,CAChB,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAU;IACnC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QACjC,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IAC7E,CAAC;AACH,CAAC;AAED,mBAA+B,IAAU,EAAE,OAAe;;QACxD,IAAI,CAAC,IAAA,qBAAa,EAAC,IAAI,EAAE,YAAY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,4BAAmB,EAAC,IAAI,CAAC,CAAA;QAC3B,CAAC,CAAA,CAAA;IACH,CAAC;CAAA"}
|
|
@@ -1,52 +1,63 @@
|
|
|
1
|
-
import { addDependenciesToPackageJson } from '@nx/devkit'
|
|
2
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'
|
|
3
|
-
import appGenerator from '@nx-dotnet/core/src/generators/app/generator';
|
|
4
|
-
import refGenerator from '@nx-dotnet/core/src/generators/nuget-reference/generator';
|
|
1
|
+
import { addDependenciesToPackageJson, readJson } from '@nx/devkit'
|
|
2
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'
|
|
5
3
|
|
|
6
|
-
import * as utils from '@abgov/nx-oc'
|
|
7
|
-
import { environments } from '@abgov/nx-oc'
|
|
8
|
-
import { Schema } from './schema'
|
|
9
|
-
import generator from './dotnet-service'
|
|
10
|
-
|
|
11
|
-
jest.mock('@nx-dotnet/core/src/generators/app/generator');
|
|
12
|
-
jest.mock('@nx-dotnet/core/src/generators/nuget-reference/generator');
|
|
13
|
-
|
|
14
|
-
const appGeneratorMock = appGenerator as jest.Mocked<typeof appGenerator>;
|
|
15
|
-
const refGeneratorMock = refGenerator as jest.Mocked<typeof refGenerator>;
|
|
4
|
+
import * as utils from '@abgov/nx-oc'
|
|
5
|
+
import { environments } from '@abgov/nx-oc'
|
|
6
|
+
import { Schema } from './schema'
|
|
7
|
+
import generator from './dotnet-service'
|
|
16
8
|
|
|
17
9
|
jest.mock('@abgov/nx-oc', () => ({
|
|
18
10
|
...jest.requireActual('@abgov/nx-oc'),
|
|
19
11
|
getAdspConfiguration: jest.fn(),
|
|
20
12
|
deploymentGenerator: jest.fn(),
|
|
21
|
-
}))
|
|
22
|
-
const utilsMock = utils as jest.Mocked<typeof utils
|
|
13
|
+
}))
|
|
14
|
+
const utilsMock = utils as jest.Mocked<typeof utils>
|
|
23
15
|
utilsMock.getAdspConfiguration.mockResolvedValue({
|
|
24
16
|
tenant: 'test',
|
|
25
17
|
tenantRealm: 'test',
|
|
26
18
|
accessServiceUrl: environments.test.accessServiceUrl,
|
|
27
19
|
directoryServiceUrl: environments.test.directoryServiceUrl,
|
|
28
|
-
})
|
|
29
|
-
utilsMock.deploymentGenerator.mockResolvedValue()
|
|
20
|
+
})
|
|
21
|
+
utilsMock.deploymentGenerator.mockResolvedValue()
|
|
30
22
|
|
|
31
23
|
describe('Dotnet Service Generator', () => {
|
|
32
24
|
const options: Schema = {
|
|
33
25
|
name: 'test',
|
|
34
26
|
env: 'dev',
|
|
35
|
-
}
|
|
27
|
+
}
|
|
36
28
|
|
|
37
29
|
it('can run', async () => {
|
|
38
|
-
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' })
|
|
30
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' })
|
|
39
31
|
addDependenciesToPackageJson(
|
|
40
32
|
host,
|
|
41
33
|
{},
|
|
42
34
|
{
|
|
43
|
-
'@nx
|
|
35
|
+
'@nx/dotnet': '^23.0.0',
|
|
44
36
|
},
|
|
45
|
-
)
|
|
46
|
-
await generator(host, options)
|
|
47
|
-
expect(
|
|
48
|
-
expect(
|
|
49
|
-
expect(
|
|
50
|
-
host.exists('
|
|
51
|
-
})
|
|
52
|
-
|
|
37
|
+
)
|
|
38
|
+
await generator(host, options)
|
|
39
|
+
expect(utils.deploymentGenerator).toHaveBeenCalled()
|
|
40
|
+
expect(host.exists('apps/test/test.csproj')).toBeTruthy()
|
|
41
|
+
expect(host.exists('apps/test/Program.cs')).toBeTruthy()
|
|
42
|
+
expect(host.exists('NuGet.Config')).toBeTruthy()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('adds @nx/dotnet to nx.json plugins', async () => {
|
|
46
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' })
|
|
47
|
+
addDependenciesToPackageJson(
|
|
48
|
+
host,
|
|
49
|
+
{},
|
|
50
|
+
{
|
|
51
|
+
'@nx/dotnet': '^23.0.0',
|
|
52
|
+
},
|
|
53
|
+
)
|
|
54
|
+
await generator(host, options)
|
|
55
|
+
const nxJson = readJson(host, 'nx.json')
|
|
56
|
+
expect(nxJson.plugins).toContain('@nx/dotnet')
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it('throws when @nx/dotnet is not installed', async () => {
|
|
60
|
+
const host = createTreeWithEmptyWorkspace({ layout: 'apps-libs' })
|
|
61
|
+
await expect(generator(host, options)).rejects.toThrow('@nx/dotnet')
|
|
62
|
+
})
|
|
63
|
+
})
|
|
@@ -4,17 +4,17 @@ namespace Adsp.Sdk.Examples;
|
|
|
4
4
|
|
|
5
5
|
public class HelloWorldEvent
|
|
6
6
|
{
|
|
7
|
-
|
|
7
|
+
public const string EventName = "hello-world-event";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
[JsonPropertyName("fromUserId")]
|
|
10
|
+
public string? FromUserId { get; set; }
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
[JsonPropertyName("fromUser")]
|
|
13
|
+
public string? FromUser { get; set; }
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
[JsonPropertyName("message")]
|
|
16
|
+
public string? Message { get; set; }
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
[JsonPropertyName("response")]
|
|
19
|
+
public string? Response { get; set; }
|
|
20
20
|
}
|
|
@@ -20,31 +20,31 @@ builder.Services.Configure<AdspOptions>(adspConfiguration);
|
|
|
20
20
|
// 2. Add ADSP components to the service collection.
|
|
21
21
|
builder.Services.AddAdspForService(options =>
|
|
22
22
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
// 3. Provide configuration of the service.
|
|
24
|
+
// 3a. Configure basic service information.
|
|
25
|
+
var serviceId = AdspId.Parse(adspConfiguration.GetValue<string>("ClientId"));
|
|
26
|
+
options.ServiceId = serviceId;
|
|
27
|
+
options.DisplayName = "<%= projectName %>";
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
// 3b. Register configuration definition.
|
|
30
|
+
options.Configuration = new ConfigurationDefinition<HelloWorldConfiguration>(
|
|
31
|
+
"Configuration of the hello world sample service.",
|
|
32
|
+
(tenant, core) => tenant
|
|
33
|
+
);
|
|
34
|
+
// Enable / disable socket.io based configuration invalidation.
|
|
35
|
+
// Include `urn:ads:platform:push-service` audience in access token; e.g use an audience mapper on the associated client.
|
|
36
|
+
options.EnableConfigurationInvalidation = false;
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
// 3c. Register service roles.
|
|
39
|
+
options.Roles = new[] {
|
|
40
40
|
new ServiceRole {
|
|
41
41
|
Role = ServiceRoles.HelloWorlder,
|
|
42
42
|
Description = "Hello worlder role that allows user to post a message to the API."
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
// 3d. Register domain events.
|
|
47
|
+
options.Events = new[] {
|
|
48
48
|
new DomainEventDefinition<HelloWorldEvent>(
|
|
49
49
|
HelloWorldEvent.EventName,
|
|
50
50
|
"Signalled when a hello world message is posted to the API."
|
|
@@ -62,7 +62,7 @@ app.UseAdsp();
|
|
|
62
62
|
app.UseAuthorization();
|
|
63
63
|
app.UseAdspMetadata(new AdspMetadataOptions
|
|
64
64
|
{
|
|
65
|
-
|
|
65
|
+
ApiPath = "WeatherForecast"
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
app.MapControllers();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<TargetFramework>net10.0</TargetFramework>
|
|
5
|
+
<Nullable>enable</Nullable>
|
|
6
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
7
|
+
<RootNamespace><%- className %></RootNamespace>
|
|
8
|
+
<AssemblyName><%- className %></AssemblyName>
|
|
9
|
+
</PropertyGroup>
|
|
10
|
+
|
|
11
|
+
<ItemGroup>
|
|
12
|
+
<PackageReference Include="Adsp.Sdk" Version="2.*" />
|
|
13
|
+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
|
|
14
|
+
</ItemGroup>
|
|
15
|
+
|
|
16
|
+
</Project>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<configuration>
|
|
3
|
+
<packageSources>
|
|
4
|
+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
|
|
5
|
+
<add key="github" value="https://nuget.pkg.github.com/GovAlta/index.json" />
|
|
6
|
+
</packageSources>
|
|
7
|
+
<packageSourceCredentials>
|
|
8
|
+
<github>
|
|
9
|
+
<add key="Username" value="%GITHUB_USER%" />
|
|
10
|
+
<add key="ClearTextPassword" value="%GITHUB_TOKEN%" />
|
|
11
|
+
</github>
|
|
12
|
+
</packageSourceCredentials>
|
|
13
|
+
</configuration>
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
"type": "string",
|
|
29
29
|
"description": "Access token for retrieving configuration from ADSP APIs.",
|
|
30
30
|
"alias": "at"
|
|
31
|
+
},
|
|
32
|
+
"tenant": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "ADSP tenant name. When provided, the realm is looked up anonymously and a single browser login is used instead of the full interactive flow.",
|
|
35
|
+
"alias": "t"
|
|
31
36
|
}
|
|
32
37
|
},
|
|
33
38
|
"required": ["name", "env"],
|