mirror of
https://github.com/selfxyz/self.git
synced 2026-02-19 02:24:25 -05:00
chore: add kmp license headers; update license year range (#1752)
* add kmp license headers and update year * formatting
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
|
||||
// SPDX-FileCopyrightText: 2025-2026 Social Connect Labs, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
|
||||
|
||||
@@ -8,7 +8,7 @@ const path = require('path');
|
||||
const { glob } = require('glob');
|
||||
|
||||
const LICENSE_HEADER_PATTERN = /^\/\/\s*SPDX-FileCopyrightText:/;
|
||||
const EXTENSIONS = ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'];
|
||||
const EXTENSIONS = ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.kt', '**/*.swift'];
|
||||
|
||||
function checkFile(filePath) {
|
||||
const content = fs.readFileSync(filePath, 'utf8');
|
||||
@@ -41,14 +41,17 @@ function main() {
|
||||
const patterns = EXTENSIONS.map(ext => path.join('src', ext));
|
||||
patterns.push(...EXTENSIONS.map(ext => path.join('tests', ext)));
|
||||
patterns.push(...EXTENSIONS.map(ext => path.join('scripts', ext)));
|
||||
patterns.push('*.ts', '*.tsx', '*.js', '*.jsx');
|
||||
patterns.push(...EXTENSIONS.map(ext => path.join('composeApp', ext)));
|
||||
patterns.push(...EXTENSIONS.map(ext => path.join('shared', ext)));
|
||||
patterns.push(...EXTENSIONS.map(ext => path.join('iosApp', ext)));
|
||||
patterns.push('*.ts', '*.tsx', '*.js', '*.jsx', '*.kt', '*.swift');
|
||||
|
||||
for (const targetDir of directories) {
|
||||
for (const pattern of patterns) {
|
||||
const files = glob
|
||||
.sync(pattern, {
|
||||
cwd: targetDir,
|
||||
ignore: ['node_modules/**', 'dist/**', 'build/**', '**/*.d.ts'],
|
||||
ignore: ['node_modules/**', 'dist/**', 'build/**', '**/*.d.ts', '.gradle/**', 'DerivedData/**', 'Pods/**', 'vendor/**'],
|
||||
})
|
||||
.map(file => path.join(targetDir, file));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
|
||||
// SPDX-FileCopyrightText: 2025-2026 Social Connect Labs, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
|
||||
|
||||
@@ -18,14 +18,14 @@ const LEGACY_HEADER =
|
||||
|
||||
// Canonical multi-line format (preferred)
|
||||
const CANONICAL_HEADER_LINES = [
|
||||
'// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.',
|
||||
'// SPDX-FileCopyrightText: 2025-2026 Social Connect Labs, Inc.',
|
||||
'// SPDX-License-Identifier: BUSL-1.1',
|
||||
'// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.',
|
||||
];
|
||||
|
||||
function findFiles(
|
||||
dir,
|
||||
extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],
|
||||
extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.kt', '.swift'],
|
||||
) {
|
||||
const files = [];
|
||||
|
||||
@@ -53,7 +53,7 @@ function findFiles(
|
||||
'DerivedData',
|
||||
'Pods',
|
||||
'.gradle',
|
||||
'iosApp',
|
||||
'vendor',
|
||||
].includes(item)
|
||||
) {
|
||||
traverse(fullPath);
|
||||
@@ -82,8 +82,11 @@ function findLicenseHeaderIndex(lines) {
|
||||
return { index: i, type: 'legacy', valid: true, endIndex: i };
|
||||
}
|
||||
|
||||
// Check for canonical multi-line format
|
||||
if (currentLine === CANONICAL_HEADER_LINES[0]) {
|
||||
// Check for canonical multi-line format (current or previous year)
|
||||
const isCurrentHeader = currentLine === CANONICAL_HEADER_LINES[0];
|
||||
const isPreviousYearHeader =
|
||||
currentLine === '// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.';
|
||||
if (isCurrentHeader || isPreviousYearHeader) {
|
||||
const hasAllLines =
|
||||
lines[i + 1] === CANONICAL_HEADER_LINES[1] &&
|
||||
lines[i + 2] === CANONICAL_HEADER_LINES[2];
|
||||
@@ -91,6 +94,7 @@ function findLicenseHeaderIndex(lines) {
|
||||
index: i,
|
||||
type: 'canonical',
|
||||
valid: hasAllLines,
|
||||
needsYearUpdate: isPreviousYearHeader && hasAllLines,
|
||||
endIndex: hasAllLines ? i + 2 : i,
|
||||
};
|
||||
}
|
||||
@@ -100,10 +104,11 @@ function findLicenseHeaderIndex(lines) {
|
||||
|
||||
function shouldRequireHeader(filePath, projectRoot) {
|
||||
const relativePath = path.relative(projectRoot, filePath);
|
||||
// Only require headers in app/ and packages/mobile-sdk-alpha/ directories
|
||||
return (
|
||||
relativePath.startsWith('app/') ||
|
||||
relativePath.startsWith('packages/mobile-sdk-alpha/')
|
||||
relativePath.startsWith('packages/mobile-sdk-alpha/') ||
|
||||
relativePath.startsWith('packages/kmp-test-app/') ||
|
||||
relativePath.startsWith('packages/kmp-sdk/')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -137,6 +142,14 @@ function checkLicenseHeader(
|
||||
};
|
||||
}
|
||||
|
||||
if (headerInfo.needsYearUpdate) {
|
||||
return {
|
||||
file: filePath,
|
||||
issue: 'Copyright year needs updating to 2025-2026',
|
||||
fixed: false,
|
||||
};
|
||||
}
|
||||
|
||||
// Check if there's a newline after the license header
|
||||
const headerEndIndex = headerInfo.endIndex;
|
||||
if (lines[headerEndIndex + 1] !== '') {
|
||||
@@ -168,6 +181,14 @@ function fixLicenseHeader(filePath) {
|
||||
}
|
||||
|
||||
if (headerInfo.valid) {
|
||||
// Update copyright year if needed
|
||||
if (headerInfo.needsYearUpdate) {
|
||||
lines[headerInfo.index] = CANONICAL_HEADER_LINES[0];
|
||||
const fixedContent = lines.join('\n');
|
||||
writeFileSync(filePath, fixedContent, 'utf8');
|
||||
return true;
|
||||
}
|
||||
|
||||
const headerEndIndex = headerInfo.endIndex;
|
||||
if (lines[headerEndIndex + 1] !== '') {
|
||||
// Insert empty line after license header
|
||||
@@ -222,7 +243,12 @@ function main() {
|
||||
|
||||
if (isCheck) {
|
||||
// Show which directories require headers
|
||||
const requiredDirs = ['app/', 'packages/mobile-sdk-alpha/'];
|
||||
const requiredDirs = [
|
||||
'app/',
|
||||
'packages/mobile-sdk-alpha/',
|
||||
'packages/kmp-test-app/',
|
||||
'packages/kmp-sdk/',
|
||||
];
|
||||
console.log(`📋 License headers required in: ${requiredDirs.join(', ')}`);
|
||||
|
||||
if (issues.length === 0) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
|
||||
// SPDX-FileCopyrightText: 2025-2026 Social Connect Labs, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
|
||||
// SPDX-FileCopyrightText: 2025-2026 Social Connect Labs, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
|
||||
// SPDX-FileCopyrightText: 2025-2026 Social Connect Labs, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user