@tama-create/sf-tools 1.4.0-dev.1 → 1.4.0-dev.10
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/config/changeset-types.txt +350 -0
- package/config/install/gitmessage +6 -0
- package/config/install/release/README.md +26 -0
- package/config/install/release/deploy-target.txt +368 -0
- package/config/install/release/remove-target.txt +279 -0
- package/config/metadata-capability.txt +118 -0
- package/config/metadata-dirs.txt +79 -0
- package/config/metasync-detect.txt +52 -0
- package/config/metasync-extra.txt +30 -0
- package/config/metasync-fingerprint.txt +90 -0
- package/dist/commands/index.js +7 -6
- package/dist/commands/launcher.js +21 -4
- package/dist/commands/pr.js +1 -1
- package/dist/commands/project.js +15 -6
- package/dist/commands/push.js +1 -1
- package/dist/commands/start.js +50 -2
- package/dist/commands/switch-org.js +1 -1
- package/dist/core/ci-sequence-steps.js +2 -2
- package/dist/core/ci-validate-steps.js +1 -1
- package/dist/core/cli-update-notice.js +47 -0
- package/dist/core/create-setup.js +47 -3
- package/dist/core/diag.js +9 -9
- package/dist/core/launcher-status.js +33 -2
- package/dist/core/log-auto.js +1 -1
- package/dist/core/log-box.js +32 -8
- package/dist/core/log-pull.js +2 -2
- package/dist/core/log-select.js +1 -1
- package/dist/core/log-start.js +2 -2
- package/dist/core/log-status.js +2 -2
- package/dist/core/metasync.js +2 -2
- package/dist/core/new-version.js +93 -0
- package/dist/core/pr.js +24 -6
- package/dist/core/project-status.js +20 -9
- package/dist/core/project-tier.js +1 -1
- package/dist/core/project-upgrade.js +138 -0
- package/dist/core/promote-check.js +46 -13
- package/dist/core/push.js +16 -5
- package/dist/core/release.js +1 -1
- package/dist/core/start.js +2 -2
- package/dist/core/update-cli.js +1 -1
- package/dist/io/create-deps.js +1 -0
- package/dist/io/job-deps.js +21 -13
- package/dist/io/keys.js +15 -4
- package/dist/io/log-deps.js +2 -1
- package/dist/io/metasync-deps.js +3 -2
- package/dist/io/promote-deps.js +4 -3
- package/dist/io/temp-dir.js +15 -1
- package/dist/io/toolbox.js +1 -1
- package/dist/ui/launcher.js +43 -12
- package/lib/apexlog.js +819 -0
- package/lib/metasync.js +1364 -0
- package/lib/package.json +4 -0
- package/lib/typecheck.js +547 -0
- package/package.json +9 -2
- package/templates/.forceignore +12 -0
- package/templates/.gitattributes +58 -0
- package/templates/.github/workflows/wf-metasync.yml +177 -0
- package/templates/.github/workflows/wf-release.yml +454 -0
- package/templates/.github/workflows/wf-sequence.yml +292 -0
- package/templates/.github/workflows/wf-validate.yml +389 -0
- package/templates/.prettierignore +11 -0
- package/templates/.prettierrc +17 -0
- package/templates/.vscode/extensions.json +9 -0
- package/templates/.vscode/launch.json +16 -0
- package/templates/.vscode/settings.json +39 -0
- package/templates/AGENTS.md +3 -0
- package/templates/CLAUDE.md +4 -0
- package/templates/README.md +11 -0
- package/templates/config/project-scratch-def.json +13 -0
- package/templates/eslint.config.js +55 -0
- package/templates/force-app/main/default/.gitkeep +0 -0
- package/templates/gitignore.template +62 -0
- package/templates/jest.config.js +6 -0
- package/templates/package.json +29 -0
- package/templates/scripts/apex/hello.apex +10 -0
- package/templates/scripts/soql/account.soql +6 -0
- package/templates/sf-tools/config/branches.txt +24 -0
- package/templates/sf-tools/config/metadata.txt +576 -0
- package/templates/sfdx-project.json +12 -0
- package/templates-ts/.github/workflows/wf-metasync.yml +109 -0
- package/templates-ts/.github/workflows/wf-release.yml +263 -0
- package/templates-ts/.github/workflows/wf-sequence.yml +153 -0
- package/templates-ts/.github/workflows/wf-validate.yml +185 -0
package/lib/package.json
ADDED
package/lib/typecheck.js
ADDED
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// ==============================================================================
|
|
3
|
+
// typecheck.js - メタデータの種類ごとの「リリース・削除」の可否を、実際の組織で確かめる(bin/sf-test-types.sh から呼ぶ)
|
|
4
|
+
// ==============================================================================
|
|
5
|
+
// 種類ごとの最小のサンプル(XML など)を、使い捨てのプロジェクトに作り、実際に、リリース → 削除して、結果を表にする。
|
|
6
|
+
// Node の標準ライブラリだけを使う(追加パッケージなし。sf CLI が npm 版のため、Node は前提)。
|
|
7
|
+
// 境界は、この 1 ファイルだけ。シェル側(bin/sf-test-types.sh)が、警告・確認・接続先の組織の種類の確認を行う。
|
|
8
|
+
//
|
|
9
|
+
// 【使い方】
|
|
10
|
+
// node lib/typecheck.js --list
|
|
11
|
+
// node lib/typecheck.js --org ALIAS --work DIR [--mode full|validate] [--only 種類,種類] [--out FILE]
|
|
12
|
+
//
|
|
13
|
+
// 【オプション】
|
|
14
|
+
// --org ALIAS : 接続先(--list 以外では必須)
|
|
15
|
+
// --work DIR : 種類ごとのプロジェクトを作るフォルダ(--list 以外では必須)。DIR/<種類>/ を、毎回、作り直す
|
|
16
|
+
// --mode full : 実際にリリースして、削除する(既定)
|
|
17
|
+
// --mode validate : 検証(sf project deploy validate)だけ。削除はしない(delete の列は unknown)
|
|
18
|
+
// --only A,B : サンプルの種類名(--list の名前)と完全一致するものだけ確認する。一致しない名前は無視する
|
|
19
|
+
// --out FILE : 結果の TSV の出力先(すべての種類を処理し終えたときだけ書く。上書き)
|
|
20
|
+
// --list : サンプルの種類の一覧(定義の順)を出して、終了する(ほかの引数の検査(下)は、先に行う)
|
|
21
|
+
// 上記以外の引数・値のないオプション・--mode の full / validate 以外の値・予約名の --org は、--list があっても、
|
|
22
|
+
// エラー(終了コード 1)
|
|
23
|
+
//
|
|
24
|
+
// 【処理の流れ】(種類ごと。定義の順)
|
|
25
|
+
// 1. DIR/<種類>/ に sfdx-project.json と force-app/main/default/ 以下のファイルを書く(1 ファイルずつ、書く前に、
|
|
26
|
+
// 安全の確認(下の【補足】)をする)。続けて、削除するメンバー名を確認する。安全の条件を満たさなければ、その時点で
|
|
27
|
+
// 全体を中断する
|
|
28
|
+
// 2. sf project deploy start(validate モードは validate)--source-dir force-app --wait 30 でリリースする。
|
|
29
|
+
// Apex を含むサンプルは --test-level RunSpecifiedTests --tests <テストクラス>
|
|
30
|
+
// 3. full モードで、リリースが成功したときだけ、削除する。削除の対象(del)を null で段階に分け、段階ごとに、
|
|
31
|
+
// 空の package.xml と destructiveChanges.xml で sf project deploy start --pre-destructive-changes を実行する。
|
|
32
|
+
// 応答に already in progress を含む失敗は、30 秒おきに最大 8 回やり直す。ある段階が失敗したら、
|
|
33
|
+
// delete = ng として、残りの段階は実行しない(サンプルが組織に残る)
|
|
34
|
+
// 4. covers(同じサンプルで確認できる別の種類)があれば、同じ結果の行を追加する
|
|
35
|
+
//
|
|
36
|
+
// 【補足】
|
|
37
|
+
// ・出力: 標準出力に、進行と結果の一覧。--out があれば、結果を TSV(見出し行なし)で書く:
|
|
38
|
+
// 種類<TAB>release<TAB>delete<TAB>備考。release / delete: ok | ng | unknown
|
|
39
|
+
// (unknown = 実行していない: validate モードの delete・release が ng のときの delete)。
|
|
40
|
+
// 組織の機能の不足による失敗も ng になる(理由は備考に出る)
|
|
41
|
+
// ・終了コード: 0 = release・delete に ng がない(--list も 0)/ 3 = ng がある / 1 = 中断(引数の誤り・安全の確認・
|
|
42
|
+
// その他の例外。メッセージは標準エラーに [ERROR] で出す)
|
|
43
|
+
// ・安全: 実行する sf のコマンドは、project deploy start / project deploy validate だけ(それ以外は、例外で中断する)
|
|
44
|
+
// ・安全: 書くファイルは、パスに SfToolsE2eMin を含むもの(ownsBody・sharedFile のサンプルは、中身に含むものも可)、
|
|
45
|
+
// 削除するメンバー名は、SfToolsE2eMin を含むものだけ。大文字・小文字を区別する。満たさなければ、全体を中断する
|
|
46
|
+
// (それまでに処理した種類のリリース・削除は、実行済みのまま。--out は書かない)。
|
|
47
|
+
// LWC のコンポーネント名は先頭が小文字でなければならないため、先頭を小文字にした sfToolsE2eMin も、含むものとして認める
|
|
48
|
+
// (認めるのは、この 2 通りの綴りだけ。それ以外の大文字・小文字の違いは、認めない)
|
|
49
|
+
// ・安全: 接続先が、共有環境の予約名(prod / staging / develop / main)なら、中断する
|
|
50
|
+
// ・カスタムオブジェクト(__c・__mdt・__e)は、削除後 15 日間、名前が予約されるため、名前に、実行時の日時(月日時分)を入れる
|
|
51
|
+
// ・成否: sf の --json の応答で、status が 0、かつ result.success が false でなければ ok。応答を JSON として読めなければ ng
|
|
52
|
+
// ・環境変数 SF_TYPECHECK_CMD: 起動するコマンドを sf から差し替える(テストで、モックの sf を使うため)
|
|
53
|
+
// ==============================================================================
|
|
54
|
+
const cp = require('child_process');
|
|
55
|
+
const fs = require('fs');
|
|
56
|
+
const path = require('path');
|
|
57
|
+
|
|
58
|
+
const API = '64.0';
|
|
59
|
+
const P = 'SfToolsE2eMin';
|
|
60
|
+
const PL = P.charAt(0).toLowerCase() + P.slice(1); // LWC のコンポーネント名は、先頭が小文字でなければならないため、この形だけも安全な名前として扱う
|
|
61
|
+
const hasP = (x) => x.includes(P) || x.includes(PL); // 安全の確認: 名前にテスト用の接頭辞を含む(大文字・小文字は区別する。許すのは P と PL の 2 通りだけ)
|
|
62
|
+
const RESERVED = ['prod', 'staging', 'develop', 'main'];
|
|
63
|
+
const NS = 'xmlns="http://soap.sforce.com/2006/04/metadata"';
|
|
64
|
+
const HEAD = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
65
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
66
|
+
const d0 = new Date();
|
|
67
|
+
const STAMP = pad(d0.getMonth() + 1) + pad(d0.getDate()) + pad(d0.getHours()) + pad(d0.getMinutes());
|
|
68
|
+
|
|
69
|
+
// 引数の解析。値を取るオプション(--org / --work / --mode / --only / --out)に、値がない(末尾・次が -- で始まる)ときは、エラー
|
|
70
|
+
function parseArgs(argv) {
|
|
71
|
+
const o = { mode: 'full' };
|
|
72
|
+
const val = (i) => {
|
|
73
|
+
const v = argv[i + 1];
|
|
74
|
+
if (v === undefined || v.startsWith('--')) throw new Error(argv[i] + ' の値がありません');
|
|
75
|
+
return v;
|
|
76
|
+
};
|
|
77
|
+
for (let i = 0; i < argv.length; i++) {
|
|
78
|
+
const a = argv[i];
|
|
79
|
+
if (a === '--org') o.org = val(i++);
|
|
80
|
+
else if (a === '--work') o.work = val(i++);
|
|
81
|
+
else if (a === '--mode') o.mode = val(i++);
|
|
82
|
+
else if (a === '--only') o.only = val(i++).split(',').filter(Boolean);
|
|
83
|
+
else if (a === '--out') o.out = val(i++);
|
|
84
|
+
else if (a === '--list') o.list = true;
|
|
85
|
+
else throw new Error('不明なオプション: ' + a);
|
|
86
|
+
}
|
|
87
|
+
return o;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const xml = (root, body) => `${HEAD}<${root} ${NS}>\n${body}\n</${root}>\n`;
|
|
91
|
+
const apexMeta = (root) => xml(root, ` <apiVersion>${API}</apiVersion>\n <status>Active</status>`);
|
|
92
|
+
|
|
93
|
+
// ---- サンプルの定義 ----
|
|
94
|
+
// files: { 相対パス(force-app/main/default からの): 本文 }
|
|
95
|
+
// del : [[種類, メンバー名], ...](削除の順。子 → 親)。null は段階の区切り(前の段階の削除が終わってから、次を削除する)
|
|
96
|
+
// extra(add の 4 つ目の引数。省略可):
|
|
97
|
+
// tests: Apex を含むときの、テストクラス(RunSpecifiedTests)
|
|
98
|
+
// covers(同じ結果の行を追加する別の種類)・notes(備考)・ownsBody / sharedFile(パスに SfToolsE2eMin を
|
|
99
|
+
// 含まないファイルを、中身に含めば書いてよい)
|
|
100
|
+
const O = P + STAMP + 'Obj'; // カスタムオブジェクト(実行ごとの別名)
|
|
101
|
+
const M = P + STAMP + 'Mdt'; // カスタムメタデータ型(実行ごとの別名)
|
|
102
|
+
const S = [];
|
|
103
|
+
const add = (type, files, del, extra) => S.push(Object.assign({ type, files, del }, extra || {}));
|
|
104
|
+
|
|
105
|
+
add('ApexClass', {
|
|
106
|
+
[`classes/${P}Cls.cls`]: `public with sharing class ${P}Cls {\n public static String hello() { return 'Hello'; }\n}\n`,
|
|
107
|
+
[`classes/${P}Cls.cls-meta.xml`]: apexMeta('ApexClass'),
|
|
108
|
+
[`classes/${P}ClsTest.cls`]: `@isTest\nprivate class ${P}ClsTest {\n @isTest static void t() { System.assertEquals('Hello', ${P}Cls.hello()); }\n}\n`,
|
|
109
|
+
[`classes/${P}ClsTest.cls-meta.xml`]: apexMeta('ApexClass'),
|
|
110
|
+
}, [['ApexClass', P + 'ClsTest'], ['ApexClass', P + 'Cls']], { tests: [P + 'ClsTest'] });
|
|
111
|
+
add('ApexTestSuite', {
|
|
112
|
+
[`classes/${P}SuiteCls.cls`]: `public with sharing class ${P}SuiteCls {\n public static String hello() { return 'Hello'; }\n}\n`,
|
|
113
|
+
[`classes/${P}SuiteCls.cls-meta.xml`]: apexMeta('ApexClass'),
|
|
114
|
+
[`classes/${P}SuiteClsTest.cls`]: `@isTest\nprivate class ${P}SuiteClsTest {\n @isTest static void t() { System.assertEquals('Hello', ${P}SuiteCls.hello()); }\n}\n`,
|
|
115
|
+
[`classes/${P}SuiteClsTest.cls-meta.xml`]: apexMeta('ApexClass'),
|
|
116
|
+
[`testSuites/${P}Suite.testSuite-meta.xml`]: xml('ApexTestSuite', ` <testClassName>${P}SuiteClsTest</testClassName>`),
|
|
117
|
+
}, [['ApexTestSuite', P + 'Suite'], ['ApexClass', P + 'SuiteClsTest'], ['ApexClass', P + 'SuiteCls']], { tests: [P + 'SuiteClsTest'] });
|
|
118
|
+
add('ApexTrigger', {
|
|
119
|
+
[`triggers/${P}Trg.trigger`]: `trigger ${P}Trg on Account (before insert) {\n for (Account a : Trigger.new) { System.debug(a.Name); }\n}\n`,
|
|
120
|
+
[`triggers/${P}Trg.trigger-meta.xml`]: apexMeta('ApexTrigger'),
|
|
121
|
+
[`classes/${P}TrgTest.cls`]: `@isTest\nprivate class ${P}TrgTest {\n @isTest static void t() { insert new Account(Name = 'x'); }\n}\n`,
|
|
122
|
+
[`classes/${P}TrgTest.cls-meta.xml`]: apexMeta('ApexClass'),
|
|
123
|
+
}, [['ApexTrigger', P + 'Trg'], ['ApexClass', P + 'TrgTest']], { tests: [P + 'TrgTest'] });
|
|
124
|
+
add('ApexPage', {
|
|
125
|
+
[`pages/${P}Page.page`]: '<apex:page><h1>Hello, World!</h1></apex:page>\n',
|
|
126
|
+
[`pages/${P}Page.page-meta.xml`]: xml('ApexPage', ` <apiVersion>${API}</apiVersion>\n <label>${P}Page</label>`),
|
|
127
|
+
}, [['ApexPage', P + 'Page']]);
|
|
128
|
+
add('ApexComponent', {
|
|
129
|
+
[`components/${P}Comp.component`]: '<apex:component><p>Hello</p></apex:component>\n',
|
|
130
|
+
[`components/${P}Comp.component-meta.xml`]: xml('ApexComponent', ` <apiVersion>${API}</apiVersion>\n <label>${P}Comp</label>`),
|
|
131
|
+
}, [['ApexComponent', P + 'Comp']]);
|
|
132
|
+
add('LightningComponentBundle', {
|
|
133
|
+
[`lwc/${P.charAt(0).toLowerCase()}${P.slice(1)}Lwc/${P.charAt(0).toLowerCase()}${P.slice(1)}Lwc.html`]: '<template><p>Hello</p></template>\n',
|
|
134
|
+
[`lwc/${P.charAt(0).toLowerCase()}${P.slice(1)}Lwc/${P.charAt(0).toLowerCase()}${P.slice(1)}Lwc.js`]: "import { LightningElement } from 'lwc';\nexport default class Hello extends LightningElement {}\n",
|
|
135
|
+
[`lwc/${P.charAt(0).toLowerCase()}${P.slice(1)}Lwc/${P.charAt(0).toLowerCase()}${P.slice(1)}Lwc.js-meta.xml`]:
|
|
136
|
+
xml('LightningComponentBundle', ` <apiVersion>${API}</apiVersion>\n <isExposed>false</isExposed>`),
|
|
137
|
+
}, [['LightningComponentBundle', `${P.charAt(0).toLowerCase()}${P.slice(1)}Lwc`]]);
|
|
138
|
+
add('AuraDefinitionBundle', {
|
|
139
|
+
[`aura/${P}Aura/${P}Aura.cmp`]: '<aura:component><p>Hello</p></aura:component>\n',
|
|
140
|
+
[`aura/${P}Aura/${P}Aura.cmp-meta.xml`]: xml('AuraDefinitionBundle', ` <apiVersion>${API}</apiVersion>\n <description>${P}</description>`),
|
|
141
|
+
}, [['AuraDefinitionBundle', P + 'Aura']]);
|
|
142
|
+
add('CustomPermission', {
|
|
143
|
+
[`customPermissions/${P}Perm.customPermission-meta.xml`]: xml('CustomPermission', ` <isLicensed>false</isLicensed>\n <label>${P}Perm</label>`),
|
|
144
|
+
}, [['CustomPermission', P + 'Perm']]);
|
|
145
|
+
add('PermissionSetGroup', {
|
|
146
|
+
[`permissionsets/${P}Ps.permissionset-meta.xml`]: xml('PermissionSet', ` <hasActivationRequired>false</hasActivationRequired>\n <label>${P}Ps</label>`),
|
|
147
|
+
[`permissionsetgroups/${P}Psg.permissionsetgroup-meta.xml`]: xml('PermissionSetGroup',
|
|
148
|
+
` <description>sf-tools</description>\n <label>${P}Psg</label>\n <permissionSets>${P}Ps</permissionSets>\n <status>Updated</status>`),
|
|
149
|
+
}, [['PermissionSetGroup', P + 'Psg'], ['PermissionSet', P + 'Ps']]);
|
|
150
|
+
add('RemoteSiteSetting', {
|
|
151
|
+
[`remoteSiteSettings/${P}Site.remoteSite-meta.xml`]: xml('RemoteSiteSetting',
|
|
152
|
+
' <disableProtocolSecurity>false</disableProtocolSecurity>\n <isActive>true</isActive>\n <url>https://example.com</url>'),
|
|
153
|
+
}, [['RemoteSiteSetting', P + 'Site']]);
|
|
154
|
+
add('CspTrustedSite', {
|
|
155
|
+
[`cspTrustedSites/${P}Csp.cspTrustedSite-meta.xml`]: xml('CspTrustedSite',
|
|
156
|
+
' <context>All</context>\n <endpointUrl>https://example.com</endpointUrl>\n <isActive>true</isActive>\n' +
|
|
157
|
+
' <isApplicableToConnectSrc>true</isApplicableToConnectSrc>\n <isApplicableToFontSrc>false</isApplicableToFontSrc>\n' +
|
|
158
|
+
' <isApplicableToFrameSrc>false</isApplicableToFrameSrc>\n <isApplicableToImgSrc>false</isApplicableToImgSrc>\n' +
|
|
159
|
+
' <isApplicableToMediaSrc>false</isApplicableToMediaSrc>\n <isApplicableToStyleSrc>false</isApplicableToStyleSrc>'),
|
|
160
|
+
}, [['CspTrustedSite', P + 'Csp']]);
|
|
161
|
+
add('CorsWhitelistOrigin', {
|
|
162
|
+
[`corsWhitelistOrigins/${P}Cors.corsWhitelistOrigin-meta.xml`]: xml('CorsWhitelistOrigin', ' <urlPattern>https://example.com</urlPattern>'),
|
|
163
|
+
}, [['CorsWhitelistOrigin', P + 'Cors']]);
|
|
164
|
+
add('Queue', {
|
|
165
|
+
[`queues/${P}Queue.queue-meta.xml`]: xml('Queue',
|
|
166
|
+
` <doesSendEmailToMembers>false</doesSendEmailToMembers>\n <name>${P}Queue</name>\n <queueSobject>\n <sobjectType>Case</sobjectType>\n </queueSobject>`),
|
|
167
|
+
}, [['Queue', P + 'Queue']]);
|
|
168
|
+
add('ExternalDataSource', {
|
|
169
|
+
[`dataSources/${P}Ds.dataSource-meta.xml`]: xml('ExternalDataSource',
|
|
170
|
+
` <endpoint>https://example.com/odata</endpoint>\n <isWritable>false</isWritable>\n <label>${P}Ds</label>\n` +
|
|
171
|
+
' <principalType>Anonymous</principalType>\n <protocol>NoAuthentication</protocol>\n <type>OData</type>'),
|
|
172
|
+
}, [['ExternalDataSource', P + 'Ds']]);
|
|
173
|
+
add('NamedCredential', {
|
|
174
|
+
[`namedCredentials/${P}Nc.namedCredential-meta.xml`]: xml('NamedCredential',
|
|
175
|
+
` <endpoint>https://example.com</endpoint>\n <label>${P}Nc</label>\n <namedCredentialType>Legacy</namedCredentialType>\n` +
|
|
176
|
+
' <principalType>Anonymous</principalType>\n <protocol>NoAuthentication</protocol>'),
|
|
177
|
+
}, [['NamedCredential', P + 'Nc']]);
|
|
178
|
+
add('GlobalValueSet', {
|
|
179
|
+
[`globalValueSets/${P}Gvs.globalValueSet-meta.xml`]: xml('GlobalValueSet',
|
|
180
|
+
` <masterLabel>${P}Gvs</masterLabel>\n <sorted>false</sorted>\n <customValue>\n <fullName>A</fullName>\n <default>false</default>\n <label>A</label>\n </customValue>`),
|
|
181
|
+
}, [['GlobalValueSet', P + 'Gvs']]);
|
|
182
|
+
add('LightningMessageChannel', {
|
|
183
|
+
[`messageChannels/${P}Chan.messageChannel-meta.xml`]: xml('LightningMessageChannel',
|
|
184
|
+
` <description>sf-tools</description>\n <isExposed>false</isExposed>\n <masterLabel>${P}Chan</masterLabel>`),
|
|
185
|
+
}, [['LightningMessageChannel', P + 'Chan']]);
|
|
186
|
+
add('PlatformEventChannel', {
|
|
187
|
+
[`platformEventChannels/${P}Ch__chn.platformEventChannel-meta.xml`]: xml('PlatformEventChannel',
|
|
188
|
+
` <channelType>event</channelType>\n <label>${P}Ch</label>`),
|
|
189
|
+
}, [['PlatformEventChannel', P + 'Ch__chn']]);
|
|
190
|
+
add('SynonymDictionary', {
|
|
191
|
+
[`synonymDictionaries/${P}Syn.synonymDictionary-meta.xml`]: xml('SynonymDictionary',
|
|
192
|
+
` <groups>\n <languages>en_US</languages>\n <terms>hello</terms>\n <terms>hi</terms>\n </groups>\n <isProtected>false</isProtected>\n <label>${P}Syn</label>`),
|
|
193
|
+
}, [['SynonymDictionary', P + 'Syn']]);
|
|
194
|
+
add('CustomTab', {
|
|
195
|
+
[`tabs/${P}Tab.tab-meta.xml`]: xml('CustomTab',
|
|
196
|
+
` <customObject>false</customObject>\n <frameHeight>600</frameHeight>\n <label>${P}Tab</label>\n <motif>Custom1: Heart</motif>\n <url>https://example.com</url>\n <urlEncodingKey>UTF-8</urlEncodingKey>`),
|
|
197
|
+
}, [['CustomTab', P + 'Tab']]);
|
|
198
|
+
add('HomePageComponent', {
|
|
199
|
+
[`homePageComponents/${P}Hpc.homePageComponent-meta.xml`]: xml('HomePageComponent',
|
|
200
|
+
' <body>hello</body>\n <pageComponentType>htmlArea</pageComponentType>\n <width>narrow</width>'),
|
|
201
|
+
}, [['HomePageComponent', P + 'Hpc']]);
|
|
202
|
+
add('HomePageLayout', {
|
|
203
|
+
[`homePageLayouts/${P}Home.homePageLayout-meta.xml`]: xml('HomePageLayout', ' <narrowComponents>standard-CreateNew</narrowComponents>\n <wideComponents>standard-Tasks</wideComponents>'),
|
|
204
|
+
}, [['HomePageLayout', P + 'Home']]);
|
|
205
|
+
add('Letterhead', {
|
|
206
|
+
[`letterhead/${P}Lh.letter-meta.xml`]: xml('Letterhead',
|
|
207
|
+
' <available>true</available>\n <backgroundColor>#FFFFFF</backgroundColor>\n <bodyColor>#FFFFFF</bodyColor>\n' +
|
|
208
|
+
' <bottomLine>\n <color>#000000</color>\n <height>1</height>\n </bottomLine>\n' +
|
|
209
|
+
' <footer>\n <backgroundColor>#FFFFFF</backgroundColor>\n <height>20</height>\n <horizontalAlignment>Left</horizontalAlignment>\n <verticalAlignment>Top</verticalAlignment>\n </footer>\n' +
|
|
210
|
+
' <header>\n <backgroundColor>#FFFFFF</backgroundColor>\n <height>20</height>\n <horizontalAlignment>Left</horizontalAlignment>\n <verticalAlignment>Top</verticalAlignment>\n </header>\n' +
|
|
211
|
+
` <middleLine>\n <color>#000000</color>\n <height>1</height>\n </middleLine>\n <name>${P}Lh</name>\n <topLine>\n <color>#000000</color>\n <height>1</height>\n </topLine>`),
|
|
212
|
+
}, [['Letterhead', P + 'Lh']]);
|
|
213
|
+
add('ReportType', {
|
|
214
|
+
[`reportTypes/${P}Rt.reportType-meta.xml`]: xml('ReportType',
|
|
215
|
+
` <baseObject>Account</baseObject>\n <category>accounts</category>\n <deployed>true</deployed>\n <description>sf-tools</description>\n <label>${P}Rt</label>\n` +
|
|
216
|
+
' <sections>\n <columns>\n <field>Name</field>\n <table>Account</table>\n </columns>\n <masterLabel>Account</masterLabel>\n </sections>'),
|
|
217
|
+
}, [['ReportType', P + 'Rt']]);
|
|
218
|
+
add('Report', {
|
|
219
|
+
[`reports/${P}Rf.reportFolder-meta.xml`]: xml('ReportFolder', ` <accessType>Hidden</accessType>\n <name>${P}Rf</name>`),
|
|
220
|
+
[`reports/${P}Rf/${P}Rep.report-meta.xml`]: xml('Report',
|
|
221
|
+
` <columns>\n <field>ACCOUNT.NAME</field>\n </columns>\n <format>Tabular</format>\n <name>${P}Rep</name>\n <reportType>AccountList</reportType>\n <scope>organization</scope>\n <showDetails>true</showDetails>`),
|
|
222
|
+
}, [['Report', `${P}Rf/${P}Rep`], ['ReportFolder', P + 'Rf']], { covers: ['ReportFolder'] });
|
|
223
|
+
add('Document', {
|
|
224
|
+
[`documents/${P}Df.documentFolder-meta.xml`]: xml('DocumentFolder',
|
|
225
|
+
` <accessType>Hidden</accessType>\n <name>${P}Df</name>\n <publicFolderAccess>ReadOnly</publicFolderAccess>`),
|
|
226
|
+
[`documents/${P}Df/${P}Doc.txt`]: 'hello\n',
|
|
227
|
+
[`documents/${P}Df/${P}Doc.document-meta.xml`]: xml('Document', ` <internalUseOnly>false</internalUseOnly>\n <name>${P}Doc</name>\n <public>false</public>`),
|
|
228
|
+
}, [['Document', `${P}Df/${P}Doc`], ['DocumentFolder', P + 'Df']], { covers: ['DocumentFolder'] });
|
|
229
|
+
add('EmailTemplate', {
|
|
230
|
+
[`email/unfiled$public/${P}Tpl.email`]: 'Hello, World!\n',
|
|
231
|
+
[`email/unfiled$public/${P}Tpl.email-meta.xml`]: xml('EmailTemplate',
|
|
232
|
+
` <available>true</available>\n <description>${P}</description>\n <encodingKey>UTF-8</encodingKey>\n <name>${P}Tpl</name>\n` +
|
|
233
|
+
` <style>none</style>\n <subject>${P}</subject>\n <type>text</type>\n <uiType>Aloha</uiType>`),
|
|
234
|
+
}, [['EmailTemplate', `unfiled$public/${P}Tpl`]]);
|
|
235
|
+
add('CustomLabel', {
|
|
236
|
+
'labels/CustomLabels.labels-meta.xml': xml('CustomLabels',
|
|
237
|
+
` <labels>\n <fullName>${P}Label</fullName>\n <language>en_US</language>\n <protected>false</protected>\n <shortDescription>${P}</shortDescription>\n <value>Hello</value>\n </labels>`),
|
|
238
|
+
}, [['CustomLabel', P + 'Label']], { ownsBody: true });
|
|
239
|
+
add('CustomObject', { // 親(+項目・Layout)。名前は、実行ごとの別名(削除後、15 日間、名前が予約されるため)
|
|
240
|
+
[`objects/${O}__c/${O}__c.object-meta.xml`]: xml('CustomObject',
|
|
241
|
+
` <deploymentStatus>Deployed</deploymentStatus>\n <label>${O}</label>\n <nameField>\n <label>Name</label>\n <type>Text</type>\n </nameField>\n` +
|
|
242
|
+
` <pluralLabel>${O}s</pluralLabel>\n <sharingModel>ReadWrite</sharingModel>`),
|
|
243
|
+
[`objects/${O}__c/fields/Note__c.field-meta.xml`]: xml('CustomField',
|
|
244
|
+
' <fullName>Note__c</fullName>\n <label>Note</label>\n <length>80</length>\n <required>false</required>\n <type>Text</type>\n <unique>false</unique>'),
|
|
245
|
+
[`layouts/${O}__c-${O} Layout.layout-meta.xml`]: xml('Layout',
|
|
246
|
+
' <layoutSections>\n <customLabel>false</customLabel>\n <detailHeading>false</detailHeading>\n <editHeading>true</editHeading>\n' +
|
|
247
|
+
' <label>Information</label>\n <layoutColumns>\n <layoutItems>\n <behavior>Required</behavior>\n <field>Name</field>\n' +
|
|
248
|
+
' </layoutItems>\n </layoutColumns>\n <style>OneColumn</style>\n </layoutSections>'),
|
|
249
|
+
}, [['CustomField', `${O}__c.Note__c`], ['CustomObject', `${O}__c`]], { notes: 'カスタムオブジェクトは、削除後 15 日間、名前が予約される' });
|
|
250
|
+
add('CustomMetadata', {
|
|
251
|
+
[`objects/${M}__mdt/${M}__mdt.object-meta.xml`]: xml('CustomObject',
|
|
252
|
+
` <label>${M}</label>\n <pluralLabel>${M}s</pluralLabel>\n <visibility>Public</visibility>`),
|
|
253
|
+
[`customMetadata/${M}.${P}Rec.md-meta.xml`]: xml('CustomMetadata', ` <label>${P}Rec</label>\n <protected>false</protected>`),
|
|
254
|
+
}, [['CustomMetadata', `${M}.${P}Rec`], ['CustomObject', `${M}__mdt`]]);
|
|
255
|
+
add('MilestoneType', {
|
|
256
|
+
[`milestoneTypes/${P}Mile.milestoneType-meta.xml`]: xml('MilestoneType', ' <recurrenceType>none</recurrenceType>'),
|
|
257
|
+
}, [['MilestoneType', P + 'Mile']]);
|
|
258
|
+
add('CustomNotificationType', {
|
|
259
|
+
[`notificationtypes/${P}Notif.notiftype-meta.xml`]: xml('CustomNotificationType',
|
|
260
|
+
` <customNotifTypeName>${P}Notif</customNotifTypeName>\n <desktop>true</desktop>\n <masterLabel>${P}Notif</masterLabel>\n <mobile>false</mobile>\n <slack>false</slack>`),
|
|
261
|
+
}, [['CustomNotificationType', P + 'Notif']]);
|
|
262
|
+
add('Workflow', { // Account に、ルール 1 つと項目自動更新 1 つを追加する(既存のものには、触れない)
|
|
263
|
+
'workflows/Account.workflow-meta.xml': xml('Workflow',
|
|
264
|
+
` <fieldUpdates>\n <fullName>${P}Fu</fullName>\n <field>Description</field>\n <formula>"x"</formula>\n <name>${P}Fu</name>\n` +
|
|
265
|
+
' <notifyAssignee>false</notifyAssignee>\n <operation>Formula</operation>\n <protected>false</protected>\n <reevaluateOnChange>false</reevaluateOnChange>\n </fieldUpdates>\n' +
|
|
266
|
+
` <rules>\n <fullName>${P}Wr</fullName>\n <actions>\n <name>${P}Fu</name>\n <type>FieldUpdate</type>\n </actions>\n <active>false</active>\n` +
|
|
267
|
+
' <criteriaItems>\n <field>Account.Name</field>\n <operation>notEqual</operation>\n <value>zzz</value>\n </criteriaItems>\n' +
|
|
268
|
+
' <triggerType>onCreateOnly</triggerType>\n </rules>'),
|
|
269
|
+
}, [['WorkflowRule', `Account.${P}Wr`], ['WorkflowFieldUpdate', `Account.${P}Fu`]], { sharedFile: true, covers: ['WorkflowRule', 'WorkflowFieldUpdate'] });
|
|
270
|
+
|
|
271
|
+
add('CustomHelpMenuSection', {
|
|
272
|
+
[`customHelpMenuSections/${P}Help.customHelpMenuSection-meta.xml`]: xml('CustomHelpMenuSection',
|
|
273
|
+
` <customHelpMenuItems>\n <linkUrl>https://example.com</linkUrl>\n <masterLabel>${P}Item</masterLabel>\n <sortOrder>1</sortOrder>\n </customHelpMenuItems>\n <masterLabel>${P}Help</masterLabel>`),
|
|
274
|
+
}, [['CustomHelpMenuSection', P + 'Help']]);
|
|
275
|
+
add('QuickAction', {
|
|
276
|
+
[`quickActions/${P}Qa.quickAction-meta.xml`]: xml('QuickAction',
|
|
277
|
+
` <label>${P}Qa</label>\n <optionsCreateFeedItem>false</optionsCreateFeedItem>\n <targetObject>Case</targetObject>\n` +
|
|
278
|
+
' <quickActionLayout>\n <layoutSectionStyle>TwoColumnsLeftToRight</layoutSectionStyle>\n <quickActionLayoutColumns>\n' +
|
|
279
|
+
' <quickActionLayoutItems>\n <emptySpace>false</emptySpace>\n <field>Subject</field>\n' +
|
|
280
|
+
' <uiBehavior>Edit</uiBehavior>\n </quickActionLayoutItems>\n </quickActionLayoutColumns>\n' +
|
|
281
|
+
' <quickActionLayoutColumns/>\n </quickActionLayout>\n <type>Create</type>'),
|
|
282
|
+
}, [['QuickAction', P + 'Qa']]);
|
|
283
|
+
add('ExternalCredential', {
|
|
284
|
+
[`externalCredentials/${P}Ec.externalCredential-meta.xml`]: xml('ExternalCredential',
|
|
285
|
+
` <authenticationProtocol>Custom</authenticationProtocol>\n <label>${P}Ec</label>`),
|
|
286
|
+
}, [['ExternalCredential', P + 'Ec']]);
|
|
287
|
+
add('ApprovalProcess', {
|
|
288
|
+
[`approvalProcesses/Account.${P}Ap.approvalProcess-meta.xml`]: xml('ApprovalProcess',
|
|
289
|
+
' <active>false</active>\n <allowRecall>false</allowRecall>\n <allowedSubmitters>\n <type>allInternalUsers</type>\n </allowedSubmitters>\n' +
|
|
290
|
+
' <approvalPageFields>\n <field>Name</field>\n </approvalPageFields>\n <approvalStep>\n <allowDelegate>false</allowDelegate>\n' +
|
|
291
|
+
' <assignedApprover>\n <approver>\n <type>adhoc</type>\n </approver>\n </assignedApprover>\n' +
|
|
292
|
+
' <label>Step1</label>\n <name>Step1</name>\n </approvalStep>\n <enableMobileDeviceAccess>false</enableMobileDeviceAccess>\n' +
|
|
293
|
+
' <entryCriteria>\n <criteriaItems>\n <field>Account.Name</field>\n <operation>notEqual</operation>\n <value>zzz</value>\n' +
|
|
294
|
+
' </criteriaItems>\n </entryCriteria>\n <finalApprovalRecordLock>false</finalApprovalRecordLock>\n' +
|
|
295
|
+
` <finalRejectionRecordLock>false</finalRejectionRecordLock>\n <label>${P}Ap</label>\n <processOrder>1</processOrder>\n` +
|
|
296
|
+
' <recordEditability>AdminOnly</recordEditability>\n <showApprovalHistory>false</showApprovalHistory>'),
|
|
297
|
+
}, [['ApprovalProcess', `Account.${P}Ap`]]);
|
|
298
|
+
add('FlexiPage', {
|
|
299
|
+
[`flexipages/${P}Page.flexipage-meta.xml`]: xml('FlexiPage',
|
|
300
|
+
` <flexiPageRegions>\n <name>main</name>\n <type>Region</type>\n </flexiPageRegions>\n <masterLabel>${P}Page</masterLabel>\n` +
|
|
301
|
+
' <template>\n <name>flexipage:defaultAppHomeTemplate</name>\n </template>\n <type>AppPage</type>'),
|
|
302
|
+
}, [['FlexiPage', P + 'Page']]);
|
|
303
|
+
add('CustomApplication', {
|
|
304
|
+
[`applications/${P}App.app-meta.xml`]: xml('CustomApplication',
|
|
305
|
+
` <formFactors>Large</formFactors>\n <isNavAutoTempTabsDisabled>false</isNavAutoTempTabsDisabled>\n <isNavPersonalizationDisabled>false</isNavPersonalizationDisabled>\n` +
|
|
306
|
+
` <label>${P}App</label>\n <navType>Standard</navType>\n <uiType>Lightning</uiType>`),
|
|
307
|
+
}, [['CustomApplication', P + 'App']]);
|
|
308
|
+
|
|
309
|
+
// ---- 追加のサンプル(2026-10-16: メタシンクの対象のうち、未確認だった種類)----
|
|
310
|
+
// 注意: 組織の機能(Omni-Channel・Entitlement・Knowledge など)が、有効でないと、リリースできない種類がある。
|
|
311
|
+
// その場合も、このファイルの結果では ng になる(種類の制限と、組織の機能の不足を、区別しない)。理由は備考に出る
|
|
312
|
+
const O2 = P + STAMP + 'Sh1'; // 共有ルール(条件)用のカスタムオブジェクト
|
|
313
|
+
const O3 = P + STAMP + 'Sh2'; // 共有ルール(所有者)用のカスタムオブジェクト
|
|
314
|
+
const EV = P + STAMP + 'Evt'; // プラットフォームイベント
|
|
315
|
+
const sharingObj = (o) => ({
|
|
316
|
+
[`objects/${o}__c/${o}__c.object-meta.xml`]: xml('CustomObject',
|
|
317
|
+
` <deploymentStatus>Deployed</deploymentStatus>\n <label>${o}</label>\n <nameField>\n <label>Name</label>\n <type>Text</type>\n </nameField>\n` +
|
|
318
|
+
` <pluralLabel>${o}s</pluralLabel>\n <sharingModel>Private</sharingModel>`),
|
|
319
|
+
[`objects/${o}__c/fields/Note__c.field-meta.xml`]: xml('CustomField',
|
|
320
|
+
' <fullName>Note__c</fullName>\n <label>Note</label>\n <length>80</length>\n <required>false</required>\n <type>Text</type>\n <unique>false</unique>'),
|
|
321
|
+
});
|
|
322
|
+
add('WorkflowAlert', {
|
|
323
|
+
[`email/unfiled$public/${P}TplWa.email`]: 'Hello\n',
|
|
324
|
+
[`email/unfiled$public/${P}TplWa.email-meta.xml`]: xml('EmailTemplate',
|
|
325
|
+
` <available>true</available>\n <description>${P}</description>\n <encodingKey>UTF-8</encodingKey>\n <name>${P}TplWa</name>\n` +
|
|
326
|
+
` <style>none</style>\n <subject>${P}</subject>\n <type>text</type>\n <uiType>Aloha</uiType>`),
|
|
327
|
+
'workflows/Account.workflow-meta.xml': xml('Workflow',
|
|
328
|
+
` <alerts>\n <fullName>${P}Wa</fullName>\n <description>${P}Wa</description>\n <protected>false</protected>\n` +
|
|
329
|
+
` <recipients>\n <type>owner</type>\n </recipients>\n <senderType>CurrentUser</senderType>\n <template>unfiled$public/${P}TplWa</template>\n </alerts>`),
|
|
330
|
+
}, [['WorkflowAlert', `Account.${P}Wa`], ['EmailTemplate', `unfiled$public/${P}TplWa`]], { sharedFile: true });
|
|
331
|
+
add('DashboardFolder', {
|
|
332
|
+
[`dashboards/${P}Dbf.dashboardFolder-meta.xml`]: xml('DashboardFolder',
|
|
333
|
+
` <accessType>Hidden</accessType>\n <name>${P}Dbf</name>\n <publicFolderAccess>ReadOnly</publicFolderAccess>`),
|
|
334
|
+
}, [['DashboardFolder', P + 'Dbf']]);
|
|
335
|
+
add('EmailFolder', {
|
|
336
|
+
[`email/${P}Ef.emailFolder-meta.xml`]: xml('EmailFolder',
|
|
337
|
+
` <accessType>Hidden</accessType>\n <name>${P}Ef</name>\n <publicFolderAccess>ReadOnly</publicFolderAccess>`),
|
|
338
|
+
}, [['EmailFolder', P + 'Ef']]);
|
|
339
|
+
add('KeywordList', {
|
|
340
|
+
[`keywords/${P}Kw.keywords-meta.xml`]: xml('KeywordList', ` <description>sf-tools</description>\n <keywords>\n <keyword>abc</keyword>\n </keywords>`),
|
|
341
|
+
}, [['KeywordList', P + 'Kw']]);
|
|
342
|
+
add('ServiceChannel', {
|
|
343
|
+
[`serviceChannels/${P}Sc.serviceChannel-meta.xml`]: xml('ServiceChannel',
|
|
344
|
+
` <label>${P}Sc</label>\n <relatedEntityType>Case</relatedEntityType>`),
|
|
345
|
+
}, [['ServiceChannel', P + 'Sc']]);
|
|
346
|
+
add('PresenceUserConfig', {
|
|
347
|
+
[`presenceUserConfigs/${P}Puc.presenceUserConfig-meta.xml`]: xml('PresenceUserConfig',
|
|
348
|
+
` <capacity>1</capacity>\n <enableAutoAccept>false</enableAutoAccept>\n <enableDecline>false</enableDecline>\n <enableDeclineReason>false</enableDeclineReason>\n` +
|
|
349
|
+
` <enableDisconnectSound>false</enableDisconnectSound>\n <enableRequestSound>false</enableRequestSound>\n` +
|
|
350
|
+
` <label>${P}Puc</label>`),
|
|
351
|
+
}, [['PresenceUserConfig', P + 'Puc']]);
|
|
352
|
+
add('QueueRoutingConfig', {
|
|
353
|
+
[`queueRoutingConfigs/${P}Qrc.queueRoutingConfig-meta.xml`]: xml('QueueRoutingConfig',
|
|
354
|
+
` <capacityWeight>1</capacityWeight>\n <label>${P}Qrc</label>\n <routingModel>LEAST_ACTIVE</routingModel>\n <routingPriority>1</routingPriority>`),
|
|
355
|
+
}, [['QueueRoutingConfig', P + 'Qrc']]);
|
|
356
|
+
add('EmailServicesFunction', {
|
|
357
|
+
[`classes/${P}EsfH.cls`]: `global class ${P}EsfH implements Messaging.InboundEmailHandler {\n global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope env) {\n return new Messaging.InboundEmailResult();\n }\n}\n`,
|
|
358
|
+
[`classes/${P}EsfH.cls-meta.xml`]: apexMeta('ApexClass'),
|
|
359
|
+
[`classes/${P}EsfHTest.cls`]: `@isTest\nprivate class ${P}EsfHTest {\n @isTest static void t() { new ${P}EsfH().handleInboundEmail(new Messaging.InboundEmail(), new Messaging.InboundEnvelope()); }\n}\n`,
|
|
360
|
+
[`classes/${P}EsfHTest.cls-meta.xml`]: apexMeta('ApexClass'),
|
|
361
|
+
[`emailservices/${P}Esf.xml`]: xml('EmailServicesFunction',
|
|
362
|
+
` <apexClass>${P}EsfH</apexClass>\n <attachmentOption>None</attachmentOption>\n <authenticationFailureAction>Discard</authenticationFailureAction>\n` +
|
|
363
|
+
` <authorizationFailureAction>Discard</authorizationFailureAction>\n <functionInactiveAction>Discard</functionInactiveAction>\n <functionName>${P}Esf</functionName>\n` +
|
|
364
|
+
' <isActive>true</isActive>\n <isAuthenticationRequired>false</isAuthenticationRequired>\n <isErrorRoutingEnabled>false</isErrorRoutingEnabled>\n' +
|
|
365
|
+
' <isTextAttachmentsAsBinary>false</isTextAttachmentsAsBinary>\n <isTlsRequired>false</isTlsRequired>\n <overLimitAction>Discard</overLimitAction>'),
|
|
366
|
+
}, [['EmailServicesFunction', P + 'Esf'], ['ApexClass', P + 'EsfHTest'], ['ApexClass', P + 'EsfH']], { tests: [P + 'EsfHTest'] });
|
|
367
|
+
add('SharingCriteriaRule', Object.assign(sharingObj(O2), {
|
|
368
|
+
[`sharingRules/${O2}__c.sharingRules-meta.xml`]: xml('SharingRules',
|
|
369
|
+
` <sharingCriteriaRules>\n <fullName>${P}Sr</fullName>\n <accessLevel>Read</accessLevel>\n <label>${P}Sr</label>\n` +
|
|
370
|
+
' <sharedTo>\n <allInternalUsers></allInternalUsers>\n </sharedTo>\n' +
|
|
371
|
+
' <criteriaItems>\n <field>Note__c</field>\n <operation>equals</operation>\n <value>a</value>\n </criteriaItems>\n' +
|
|
372
|
+
' <includeRecordsOwnedByAll>false</includeRecordsOwnedByAll>\n </sharingCriteriaRules>'),
|
|
373
|
+
}), [['SharingCriteriaRule', `${O2}__c.${P}Sr`], null, ['CustomField', `${O2}__c.Note__c`], ['CustomObject', `${O2}__c`]],
|
|
374
|
+
{ covers: ['SharingRules'], notes: 'カスタムオブジェクトは、削除後 15 日間、名前が予約される' });
|
|
375
|
+
add('SharingOwnerRule', Object.assign(sharingObj(O3), {
|
|
376
|
+
[`sharingRules/${O3}__c.sharingRules-meta.xml`]: xml('SharingRules',
|
|
377
|
+
` <sharingOwnerRules>\n <fullName>${P}So</fullName>\n <accessLevel>Read</accessLevel>\n <label>${P}So</label>\n` +
|
|
378
|
+
' <sharedTo>\n <allInternalUsers></allInternalUsers>\n </sharedTo>\n' +
|
|
379
|
+
' <sharedFrom>\n <allInternalUsers></allInternalUsers>\n </sharedFrom>\n </sharingOwnerRules>'),
|
|
380
|
+
}), [['SharingOwnerRule', `${O3}__c.${P}So`], null, ['CustomField', `${O3}__c.Note__c`], ['CustomObject', `${O3}__c`]],
|
|
381
|
+
{ notes: 'カスタムオブジェクトは、削除後 15 日間、名前が予約される' });
|
|
382
|
+
add('PlatformEventChannelMember', {
|
|
383
|
+
[`objects/${EV}__e/${EV}__e.object-meta.xml`]: xml('CustomObject',
|
|
384
|
+
` <deploymentStatus>Deployed</deploymentStatus>\n <eventType>HighVolume</eventType>\n <label>${EV}</label>\n <pluralLabel>${EV}s</pluralLabel>\n <publishBehavior>PublishAfterCommit</publishBehavior>`),
|
|
385
|
+
[`platformEventChannels/${P}Mc__chn.platformEventChannel-meta.xml`]: xml('PlatformEventChannel', ` <channelType>event</channelType>\n <label>${P}Mc</label>`),
|
|
386
|
+
[`platformEventChannelMembers/${P}Mem.platformEventChannelMember-meta.xml`]: xml('PlatformEventChannelMember',
|
|
387
|
+
` <eventChannel>${P}Mc__chn</eventChannel>\n <selectedEntity>${EV}__e</selectedEntity>`),
|
|
388
|
+
}, [['PlatformEventChannelMember', `${P}Mem`], ['PlatformEventChannel', P + 'Mc__chn'], ['CustomObject', `${EV}__e`]],
|
|
389
|
+
{ notes: 'カスタムオブジェクトは、削除後 15 日間、名前が予約される' });
|
|
390
|
+
add('Profile', {
|
|
391
|
+
[`profiles/${P}Prof.profile-meta.xml`]: xml('Profile', ' <custom>true</custom>\n <userLicense>Salesforce</userLicense>'),
|
|
392
|
+
}, [['Profile', P + 'Prof']]);
|
|
393
|
+
add('CustomPageWebLink', {
|
|
394
|
+
[`weblinks/${P}Wl.weblink-meta.xml`]: xml('CustomPageWebLink',
|
|
395
|
+
` <availability>online</availability>\n <displayType>link</displayType>\n <encodingKey>UTF-8</encodingKey>\n <linkType>url</linkType>\n <masterLabel>${P}Wl</masterLabel>\n` +
|
|
396
|
+
' <openType>newWindow</openType>\n <position>none</position>\n <protected>false</protected>\n <url>https://example.com</url>'),
|
|
397
|
+
}, [['CustomPageWebLink', P + 'Wl']]);
|
|
398
|
+
add('WebLink', { // Account に、カスタムボタンを 1 つ追加する(既存のものには、触れない)
|
|
399
|
+
[`objects/Account/webLinks/${P}Bt.webLink-meta.xml`]: xml('WebLink',
|
|
400
|
+
` <fullName>${P}Bt</fullName>\n <availability>online</availability>\n <displayType>button</displayType>\n <encodingKey>UTF-8</encodingKey>\n <linkType>url</linkType>\n` +
|
|
401
|
+
` <masterLabel>${P}Bt</masterLabel>\n <openType>replace</openType>\n <protected>false</protected>\n <url>https://example.com</url>`),
|
|
402
|
+
}, [['WebLink', `Account.${P}Bt`]]);
|
|
403
|
+
add('ContentAsset', {
|
|
404
|
+
[`contentassets/${P}Asset.asset`]: 'hello\n',
|
|
405
|
+
[`contentassets/${P}Asset.asset-meta.xml`]: xml('ContentAsset',
|
|
406
|
+
` <isVisibleByExternalUsers>false</isVisibleByExternalUsers>\n <language>en_US</language>\n <masterLabel>${P}Asset</masterLabel>\n` +
|
|
407
|
+
` <versions>\n <version>\n <number>1</number>\n <pathOnClient>${P}Asset.txt</pathOnClient>\n </version>\n </versions>`),
|
|
408
|
+
}, [['ContentAsset', P + 'Asset']]);
|
|
409
|
+
add('DataCategoryGroup', {
|
|
410
|
+
[`datacategorygroups/${P}Dcg.datacategorygroup-meta.xml`]: xml('DataCategoryGroup',
|
|
411
|
+
` <active>false</active>\n <dataCategory>\n <label>All</label>\n <name>All</name>\n </dataCategory>\n <description>sf-tools</description>\n <label>${P}Dcg</label>`),
|
|
412
|
+
}, [['DataCategoryGroup', P + 'Dcg']]);
|
|
413
|
+
add('EntitlementTemplate', {
|
|
414
|
+
[`entitlementTemplates/${P}Et.entitlementTemplate-meta.xml`]: xml('EntitlementTemplate',
|
|
415
|
+
' <casesPerEntitlement>1</casesPerEntitlement>\n <isPerIncident>true</isPerIncident>\n <term>12</term>\n <type>Phone Support</type>'),
|
|
416
|
+
}, [['EntitlementTemplate', P + 'Et']]);
|
|
417
|
+
add('ExternalServiceRegistration', {
|
|
418
|
+
[`namedCredentials/${P}NcEsr.namedCredential-meta.xml`]: xml('NamedCredential',
|
|
419
|
+
` <endpoint>https://example.com</endpoint>\n <label>${P}NcEsr</label>\n <namedCredentialType>Legacy</namedCredentialType>\n` +
|
|
420
|
+
' <principalType>Anonymous</principalType>\n <protocol>NoAuthentication</protocol>'),
|
|
421
|
+
[`externalServiceRegistrations/${P}Esr.externalServiceRegistration-meta.xml`]: xml('ExternalServiceRegistration',
|
|
422
|
+
` <label>${P}Esr</label>\n <namedCredential>${P}NcEsr</namedCredential>\n <registrationProviderType>Custom</registrationProviderType>\n` +
|
|
423
|
+
' <schema>{"openapi":"3.0.0","info":{"title":"t","version":"1.0"},"servers":[{"url":"https://example.com"}],' +
|
|
424
|
+
'"paths":{"/ping":{"get":{"operationId":"ping","responses":{"200":{"description":"ok"}}}}}}</schema>\n' +
|
|
425
|
+
' <schemaType>OpenApi3</schemaType>\n <status>Complete</status>'),
|
|
426
|
+
}, [['ExternalServiceRegistration', P + 'Esr'], ['NamedCredential', P + 'NcEsr']]);
|
|
427
|
+
|
|
428
|
+
// 進行の表示: 「[時:分:秒] メッセージ」を標準出力に出す
|
|
429
|
+
function log(m) {
|
|
430
|
+
const d = new Date();
|
|
431
|
+
console.log(`[${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}] ${m}`);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const ALLOWED = ['project deploy start', 'project deploy validate'];
|
|
435
|
+
// sf の起動: 引数は、シェルを通して渡すため、引用符で囲む(名前に $ や空白を含む: unfiled$public/..、Layout の名前)。
|
|
436
|
+
// 環境変数 SF_TYPECHECK_CMD で、起動するコマンドを差し替えられる(テストで、モックの sf を使うため。引用符で囲まずに、そのまま先頭に置く)
|
|
437
|
+
function quote(a) {
|
|
438
|
+
const s = String(a);
|
|
439
|
+
// POSIX: ' を '\'' にする(JS の文字列では "'\\''"。"'\''" と書くと、\' が ' になり、''' という誤った置換になる)
|
|
440
|
+
return process.platform === 'win32' ? '"' + s.replace(/"/g, '\\"') + '"' : "'" + s.replace(/'/g, "'\\''") + "'";
|
|
441
|
+
}
|
|
442
|
+
// sf の実行: 引数の先頭 3 語が ALLOWED(project deploy start / validate)でなければ、例外で中断する。--json を末尾に付ける。
|
|
443
|
+
// 戻り値: { j: 応答の JSON(最初の { から読む。読めなければ { status: 1, message: 出力の末尾 300 文字 }), sec: 所要秒 }
|
|
444
|
+
function sf(argv, cwd) {
|
|
445
|
+
const sub = argv.slice(0, 3).join(' ');
|
|
446
|
+
if (!ALLOWED.includes(sub)) throw new Error('許可していない sf のコマンドです: ' + sub);
|
|
447
|
+
const t0 = Date.now();
|
|
448
|
+
const cmd = (process.env.SF_TYPECHECK_CMD || 'sf') + ' ' + argv.concat('--json').map(quote).join(' ');
|
|
449
|
+
const r = cp.spawnSync(cmd, { cwd, encoding: 'utf8', shell: true, maxBuffer: 64 * 1024 * 1024 });
|
|
450
|
+
let j;
|
|
451
|
+
const out = r.stdout || '';
|
|
452
|
+
try { j = JSON.parse(out.slice(out.indexOf('{'))); } catch (e) { j = { status: 1, message: (out || r.stderr || '').slice(-300) }; }
|
|
453
|
+
return { j, sec: Math.round((Date.now() - t0) / 100) / 10 };
|
|
454
|
+
}
|
|
455
|
+
// 成否: status が 0、かつ result.success が false でなければ ok
|
|
456
|
+
const okOf = (j) => j.status === 0 && ((j.result || {}).success !== false);
|
|
457
|
+
// 失敗の理由(備考用): componentFailures の最初の 2 件(種類・名前・問題の先頭 120 文字)。なければ message
|
|
458
|
+
// (なければ result.errorMessage)の空白を詰めた先頭 200 文字
|
|
459
|
+
function why(j) {
|
|
460
|
+
const r = j.result || {};
|
|
461
|
+
let cf = (r.details || {}).componentFailures || [];
|
|
462
|
+
if (!Array.isArray(cf)) cf = [cf];
|
|
463
|
+
if (cf.length) return cf.slice(0, 2).map((f) => `${f.componentType || ''} ${f.fullName || ''}: ${(f.problem || '').slice(0, 120)}`).join(' | ');
|
|
464
|
+
return String(j.message || r.errorMessage || '').replace(/\s+/g, ' ').slice(0, 200);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function main() {
|
|
468
|
+
const o = parseArgs(process.argv.slice(2));
|
|
469
|
+
// 引数の値の検査は、--list より先に行う(--list があっても、--mode の誤り・予約名の --org は、エラーにする)
|
|
470
|
+
if (!['full', 'validate'].includes(o.mode)) throw new Error('--mode は full または validate');
|
|
471
|
+
if (o.org !== undefined && RESERVED.includes(o.org)) throw new Error('共有環境の予約名(' + o.org + ')には、実行できません');
|
|
472
|
+
if (o.list) { S.forEach((s) => console.log(s.type)); return 0; }
|
|
473
|
+
if (!o.org || !o.work) throw new Error('--org と --work が必要です');
|
|
474
|
+
const list = S.filter((s) => !o.only || o.only.includes(s.type));
|
|
475
|
+
fs.mkdirSync(o.work, { recursive: true });
|
|
476
|
+
const rows = [];
|
|
477
|
+
log(`種類ごとの確認(${o.mode}): ${list.length} 種類。組織: ${o.org}`);
|
|
478
|
+
list.forEach((s, i) => {
|
|
479
|
+
const dir = path.join(o.work, s.type.replace(/[^A-Za-z0-9_]/g, '_'));
|
|
480
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
481
|
+
fs.mkdirSync(path.join(dir, 'force-app', 'main', 'default'), { recursive: true });
|
|
482
|
+
fs.writeFileSync(path.join(dir, 'sfdx-project.json'), '{"packageDirectories":[{"path":"force-app","default":true}],"sourceApiVersion":"' + API + '"}');
|
|
483
|
+
// 安全: 作成するファイルは、パスに SfToolsE2eMin を含むもの(ownsBody・sharedFile のサンプルは、中身に含むものも可)だけ。
|
|
484
|
+
// 大文字・小文字を区別する(LWC のサンプル lwc/sfToolsE2eMinLwc/ は、先頭が小文字の綴りも認める hasP で確認する)。
|
|
485
|
+
// P + STAMP(実行ごとの別名)を含むパスは、hasP でも真になる(その条件は、念のための重ね)
|
|
486
|
+
for (const [rel, body] of Object.entries(s.files)) {
|
|
487
|
+
if (!(hasP(rel) || (s.ownsBody || s.sharedFile) && hasP(body)) && !rel.includes(P + STAMP)) {
|
|
488
|
+
throw new Error('安全のため中断: 名前に ' + P + ' を含まないファイルです: ' + rel);
|
|
489
|
+
}
|
|
490
|
+
const dst = path.join(dir, 'force-app', 'main', 'default', ...rel.split('/'));
|
|
491
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
492
|
+
fs.writeFileSync(dst, body, 'utf8');
|
|
493
|
+
}
|
|
494
|
+
for (const [t, m] of s.del.filter(Boolean)) if (!hasP(m)) throw new Error('安全のため中断: 削除対象の名前に ' + P + ' を含みません: ' + m);
|
|
495
|
+
const row = { type: s.type, release: 'unknown', delete: 'unknown', note: s.notes || '' };
|
|
496
|
+
log(`(${i + 1}/${list.length}) ${s.type}`);
|
|
497
|
+
const extra = s.tests ? ['--test-level', 'RunSpecifiedTests'].concat(...s.tests.map((x) => ['--tests', x])) : [];
|
|
498
|
+
const cmd = o.mode === 'full' ? 'start' : 'validate';
|
|
499
|
+
const r1 = sf(['project', 'deploy', cmd, '--source-dir', 'force-app', '--target-org', o.org, '--wait', '30'].concat(extra), dir);
|
|
500
|
+
row.release = okOf(r1.j) ? 'ok' : 'ng';
|
|
501
|
+
if (row.release === 'ng') row.note = ('リリース: ' + why(r1.j)).slice(0, 220);
|
|
502
|
+
log(` リリース${o.mode === 'validate' ? '(検証)' : ''} ${row.release}(${r1.sec} 秒)${row.release === 'ok' ? '' : ' ' + why(r1.j).slice(0, 150)}`);
|
|
503
|
+
if (o.mode === 'full' && row.release === 'ok') {
|
|
504
|
+
// 削除は、null で区切った段階ごとに、順に実行する(例: 共有ルールの削除が終わってから、オブジェクトを削除する)
|
|
505
|
+
const steps = [[]];
|
|
506
|
+
s.del.forEach((d) => { if (d === null) steps.push([]); else steps[steps.length - 1].push(d); });
|
|
507
|
+
fs.writeFileSync(path.join(dir, 'package.xml'), `${HEAD}<Package ${NS}><version>${API}</version></Package>`);
|
|
508
|
+
row.delete = 'ok';
|
|
509
|
+
let secTotal = 0;
|
|
510
|
+
for (const st of steps) {
|
|
511
|
+
const by = {};
|
|
512
|
+
st.forEach(([t, m]) => { (by[t] = by[t] || []).push(m); });
|
|
513
|
+
const types = Object.entries(by).map(([t, ms]) => `<types>${ms.map((m) => `<members>${m}</members>`).join('')}<name>${t}</name></types>`).join('');
|
|
514
|
+
fs.writeFileSync(path.join(dir, 'destructiveChanges.xml'), `${HEAD}<Package ${NS}>${types}<version>${API}</version></Package>`);
|
|
515
|
+
let r2 = sf(['project', 'deploy', 'start', '--manifest', 'package.xml', '--pre-destructive-changes', 'destructiveChanges.xml', '--target-org', o.org, '--wait', '30'], dir);
|
|
516
|
+
secTotal += r2.sec;
|
|
517
|
+
// 共有の再計算が終わるまで、削除が失敗する(already in progress)。30 秒おきに、最大 8 回、やり直す
|
|
518
|
+
for (let n = 0; n < 8 && !okOf(r2.j) && /already in progress/.test(JSON.stringify(r2.j)); n++) {
|
|
519
|
+
log(` 共有の再計算の完了を待っています(${n + 1}/8)`);
|
|
520
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 30000);
|
|
521
|
+
r2 = sf(['project', 'deploy', 'start', '--manifest', 'package.xml', '--pre-destructive-changes', 'destructiveChanges.xml', '--target-org', o.org, '--wait', '30'], dir);
|
|
522
|
+
secTotal += r2.sec;
|
|
523
|
+
}
|
|
524
|
+
if (!okOf(r2.j)) {
|
|
525
|
+
row.delete = 'ng';
|
|
526
|
+
row.note = (row.note + ' 削除: ' + why(r2.j)).trim().slice(0, 220);
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
log(` 削除 ${row.delete}(${Math.round(secTotal * 10) / 10} 秒)${row.delete === 'ok' ? '' : ' ' + row.note.slice(0, 150)}`);
|
|
531
|
+
}
|
|
532
|
+
rows.push(row);
|
|
533
|
+
// 同じサンプルの中で、一緒に確認できた別の種類(covers)も、同じ結果の行にする
|
|
534
|
+
(s.covers || []).forEach((t) => rows.push(Object.assign({}, row, { type: t, note: ('(' + s.type + ' のサンプルと同時に確認)' + row.note).trim() })));
|
|
535
|
+
});
|
|
536
|
+
log('=== 結果 ===');
|
|
537
|
+
rows.forEach((r) => log(`${r.type.padEnd(28)} release=${r.release.padEnd(7)} delete=${r.delete.padEnd(7)} ${r.note.slice(0, 100)}`));
|
|
538
|
+
log(`リリース ok ${rows.filter((r) => r.release === 'ok').length} / 削除 ok ${rows.filter((r) => r.delete === 'ok').length}(全 ${rows.length} 種類)`);
|
|
539
|
+
if (o.out) {
|
|
540
|
+
fs.writeFileSync(o.out, rows.map((r) => [r.type, r.release, r.delete, r.note.replace(/[\t\r\n]+/g, ' ')].join('\t')).join('\n') + '\n', 'utf8');
|
|
541
|
+
log('結果を書きました: ' + o.out);
|
|
542
|
+
}
|
|
543
|
+
const ng = rows.filter((r) => r.release === 'ng' || r.delete === 'ng').length;
|
|
544
|
+
return ng === 0 ? 0 : 3;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
try { process.exitCode = main(); } catch (e) { console.error('[ERROR] ' + e.message); process.exitCode = 1; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tama-create/sf-tools",
|
|
3
|
-
"version": "1.4.0-dev.
|
|
3
|
+
"version": "1.4.0-dev.10",
|
|
4
4
|
"description": "Salesforce 開発の環境構築と毎日の作業を自動化する(TypeScript 版・開発中)",
|
|
5
5
|
"license": "Unlicense",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,14 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"bin/sft.js",
|
|
16
|
-
"dist/"
|
|
16
|
+
"dist/",
|
|
17
|
+
"lib/apexlog.js",
|
|
18
|
+
"lib/metasync.js",
|
|
19
|
+
"lib/typecheck.js",
|
|
20
|
+
"lib/package.json",
|
|
21
|
+
"config/",
|
|
22
|
+
"templates/",
|
|
23
|
+
"templates-ts/"
|
|
17
24
|
],
|
|
18
25
|
"engines": {
|
|
19
26
|
"node": ">=24"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
|
|
2
|
+
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
package.xml
|
|
6
|
+
|
|
7
|
+
# LWC configuration files
|
|
8
|
+
**/jsconfig.json
|
|
9
|
+
**/.eslintrc.json
|
|
10
|
+
|
|
11
|
+
# LWC Jest
|
|
12
|
+
**/__tests__/**
|